Ron Koenderink [Sun, 19 Aug 2007 01:47:43 +0000 (01:47 +0000)]
(strptime) [_WIN32]: Postpone the declaration of the struct tm for strptime().
Pick up the declaration for struct tm when time.h is included in the source file.
Ron Koenderink [Sun, 19 Aug 2007 01:37:25 +0000 (01:37 +0000)]
(getopt) [_WIN32]: In order to prevent namespace conflict between MSC and
MinGW created an extern getopt() in unistd.h. MinGW has getopt() in the library.
MSC does not have getopt() function.
Ron Koenderink [Thu, 16 Aug 2007 03:03:22 +0000 (03:03 +0000)]
(ssize_t, pid_t) [_WIN32]: Back out the previous revision of unistd.h
and move to w32misc.h instead. Belong into sys/types.h but we can't
fix system headers.
Ron Koenderink [Wed, 15 Aug 2007 01:16:26 +0000 (01:16 +0000)]
Create w32misc.h to contain information that does not fit in Windows
equivalent include file.
(strptime) [_WIN32]: Add extern for WIN32 equivalent for strptime().
Ron Koenderink [Tue, 14 Aug 2007 03:11:26 +0000 (03:11 +0000)]
[_WIN32] (posix_mkdir): New.
[_WIN32] (mkdir): Use it. Last argument is no longer ignored, which
was a bug. Move declaration to unistd.h, which isn't quite right, but
works for us.
Fix fields checks for split tables:
(caseen): Remove.
(xufldhdr, deffld): Record only fields in this part in caflds[]. This
fixes the check for duplicate fields in parts other than the first.
(cafldspp): New, to record fields in previous parts.
(xundump): Initialize and finalize it.
(xufooter): Update it. Requires new parameter ca. Caller changed.
(fldval_must_match): Use it to do the right thing for split arrays.
(chkflds): Adapt for changed caflds[].
(chkflds): The check for missing fields was skipped for all parts of a
split table instead of for all but the final part.
(xufldhdr): ellipsis wasn't cleared for machine-readable input. This
broke reading machine-readable input after reading a split table
failed before seeing the last part. Luckily, callers never tried
that.
New home for stuff specific to Windows: src/lib/w32/
Move getopt.c getopt.h service.c from src/lib/gen/ there.
(lib/libw32.a): New.
(libs): Add it under Windows.
Ron Koenderink [Fri, 3 Aug 2007 01:47:02 +0000 (01:47 +0000)]
(fmttime2822) [_WIN32]: Replace localtime_s() with localtime().
Replace _snprintf_s() with _snprintf(). These secure functions are
not supported by MinGW yet.
(fl_sct_init, write_sects, file_sct_init, main): Do not initialize
sector and realm timestamps to current time. It's not useful, and it
facilitates attacks against the PRNG. This backs out fairland.c
rev. 1.27 and files.c rev. 1.31 and partly backs out files.c
rev. 1.38.
Store update disable flag in the game table to make it visible in
xdump:
(gamestr): New member game_upd_disable.
(game_ca): Update accordingly.
(game_ctrl_update): New.
(disa, enab): Use it.
(updates_disabled): Rewrite and move to game.c
(disablefil): Remove.
Ron Koenderink [Thu, 26 Jul 2007 01:59:32 +0000 (01:59 +0000)]
(fmttime2822): Changed return type for strftime() to size_t.
(fmttime2822) [_WIN32]: %T is not support option for strftime in WIN32
replaced with %H:%M:%S. Replaced %z in with +/-???? format for WIN32
as the default for WIN32 is the text description for timezone.
(player_kill_idle): Don't kill hung player threads. That code was
flawed. Firstly, when player_kill_idle() ran before the player thread
could react to being aborted by update or shutdown, player_kill_idle()
incorrectly diagnosed it as hung. Secondly, terminating hung threads
leaks resources and can leave a stale play_lock behind. It could
perhaps even corrupt game state. It might salvage some scenarios, but
makes others worse. Not worth it.
Remove the concept of thread priorities from empthread.h. Only LWP
supports priorities. Update synchronization used to rely on them,
which naturally worked only with LWP (#1504036). With that fixed, no
uses of priorities remained, but a minor bug did: players could starve
out threads with priorities below PP_PLAYER, i.e. delete_lostitems()
and player_kill_idle(). Closes #1458175:
(empth_create): Remove parameter prio. Callers changed. Also gets
rid of misleading comments in pthread.c and ntthread.c.
(PP_MAIN, PP_UPDATE, PP_SHUTDOWN, PP_SCHED, PP_TIMESTAMP, PP_PLAYER)
(PP_ACCEPT, PP_KILLIDLE): Remove.
(empth_init, empth_create) [EMPTH_LWP]: Pass priority 1.
(dispatch): Set player->command before acquiring play_lock, to make
sure the command is reliably aborted on update and shutdown. Before,
redirection output could block while player->command was still null,
letting players delay the update or shutdown indefinitely.
(dispatch): Rwlocks can hand out read locks while a write lock is
wanted. Unfair to writers, but possible. This lets commands run with
!player->aborted, which can then block on input and thus let players
delay the update or shutdown indefinitely. Avoid by spinning until
the update is done.