From 0a8f21e6a44d59a3333c0b4fee572fe6d94aae3d Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sun, 11 Sep 2011 21:44:23 +0100 Subject: [PATCH] Move abort() into opr We need our own abort function, because the behaviour of the Windows abort() implementation isn't sufficiently flexible for us. Because we're replacing an operating system function, reather than implementing a missing function, this doesn't belong in roken. So, provide an alternative opr_abort() implementation in our portable runtime layer, which is a synonym for abort() on Unix, and implements the required DebugBreak() functionality on Windows. Remove lwp_abort() which was just creating another, unnecessary, layer of abstraction. Change-Id: Ice226d70d2791beaba011f42e39fde60242f6cc3 Reviewed-on: http://gerrit.openafs.org/4428 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/WINNT/client_exp/NTMakefile | 1 + src/lwp/iomgr.c | 10 ++++------ src/lwp/lwp.h | 3 --- src/lwp/lwp_nt.c | 15 ++------------- src/opr/Makefile.in | 5 +++-- src/opr/NTMakefile | 1 + src/opr/assert.c | 15 +++++++++++++++ src/opr/opr.h | 9 ++++++++- src/rx/rx_user.c | 2 +- src/rx/test/NTMakefile | 3 ++- src/rx/test/testclient.c | 4 +++- src/rx/test/testserver.c | 4 +++- src/rxdebug/NTMakefile | 3 ++- src/util/afsutil.h | 10 ---------- src/util/assert.c | 11 ++--------- src/xstat/NTMakefile | 3 ++- 16 files changed, 49 insertions(+), 50 deletions(-) create mode 100644 src/opr/assert.c diff --git a/src/WINNT/client_exp/NTMakefile b/src/WINNT/client_exp/NTMakefile index e7c9830cd..31f33bea0 100644 --- a/src/WINNT/client_exp/NTMakefile +++ b/src/WINNT/client_exp/NTMakefile @@ -84,6 +84,7 @@ DLLLIBS =\ $(DESTDIR)\lib\afs\TaLocaleU.lib \ $(DESTDIR)\lib\afs\mtafsutil.lib \ $(DESTDIR)\lib\afsroken.lib \ + $(DESTDIR)\lib\opr.lib \ $(DESTDIR)\lib\libafsconf.lib $(DLLFILE): $(DLLOBJS) $(DLLLIBS) diff --git a/src/lwp/iomgr.c b/src/lwp/iomgr.c index b0148ea44..2ed325a6d 100644 --- a/src/lwp/iomgr.c +++ b/src/lwp/iomgr.c @@ -38,14 +38,12 @@ #include -#ifdef AFS_NT40_ENV -extern void lwp_abort(void); -#endif /* AFS_NT40_ENV */ - #ifdef HAVE_SYS_SELECT_H #include #endif +#include + #include "lwp.h" #include "timer.h" @@ -552,7 +550,7 @@ static void *IOMGR(void *dummy) } #endif iomgr_errno = errno; - lwp_abort(); + opr_abort(); } } @@ -834,7 +832,7 @@ int IOMGR_Select(int fds, fd_set *readfds, fd_set *writefds, fprintf(stderr, "IOMGR_Select: fds=%d, more than max %d\n", fds, FD_SETSIZE); fflush(stderr); - lwp_abort(); + opr_abort(); } #endif diff --git a/src/lwp/lwp.h b/src/lwp/lwp.h index a94209e88..3b58c5917 100644 --- a/src/lwp/lwp.h +++ b/src/lwp/lwp.h @@ -72,9 +72,6 @@ extern unsigned int FT_ApproxTime(void); #define LWP_ENOROCKS -15 /* all rocks are in use */ #define LWP_EBADROCK -16 /* the specified rock does not exist */ -#ifndef AFS_NT40_ENV -#define lwp_abort() abort() -#endif /* Maximum priority permissible (minimum is always 0) */ #define LWP_MAX_PRIORITY 4 /* changed from 1 */ diff --git a/src/lwp/lwp_nt.c b/src/lwp/lwp_nt.c index 147a91a2b..c37baebda 100644 --- a/src/lwp/lwp_nt.c +++ b/src/lwp/lwp_nt.c @@ -22,6 +22,7 @@ #include #ifdef AFS_NT40_ENV +#include #include #include "lwp.h" @@ -54,7 +55,6 @@ char lwp_debug = 0; /* Forward declarations */ static void Dispatcher(void); -static void Exit_LWP(void); static void Abort_LWP(char *msg); static VOID WINAPI Enter_LWP(PVOID fiberData); static void Initialize_PCB(PROCESS pcb, int priority, int stacksize, @@ -519,7 +519,7 @@ static void Abort_LWP(char *msg) printf("***LWP: Abort --- dumping PCBs ...\n"); Dump_Processes(); #endif - Exit_LWP(); + opr_abort(); } #ifdef DEBUG @@ -606,17 +606,6 @@ static void Dispatcher(void) SwitchToFiber(lwp_cpptr->fiber); } -void lwp_abort(void) -{ - afs_NTAbort(); -} - -static void Exit_LWP(void) -{ - - lwp_abort(); -} - static void Delete_PCB(PROCESS pid) { Debug(4, ("Entered Delete_PCB")) diff --git a/src/opr/Makefile.in b/src/opr/Makefile.in index d339cfc03..566cdbe82 100644 --- a/src/opr/Makefile.in +++ b/src/opr/Makefile.in @@ -2,9 +2,10 @@ srcdir=@srcdir@ include @TOP_OBJDIR@/src/config/Makefile.config include @TOP_OBJDIR@/src/config/Makefile.pthread -objects = casestrcpy.o +objects = assert.o casestrcpy.o -all: $(TOP_INCDIR)/afs/opr.h $(TOP_LIBDIR)/libopr.a +all: $(TOP_INCDIR)/afs/opr.h \ + $(TOP_LIBDIR)/libopr.a libopr.a: $(objects) -$(RM) -f $@ diff --git a/src/opr/NTMakefile b/src/opr/NTMakefile index 6784827e4..a10ee520d 100644 --- a/src/opr/NTMakefile +++ b/src/opr/NTMakefile @@ -16,6 +16,7 @@ INCFILES = \ LIBFILE = $(DESTDIR)\lib\opr.lib LIBOBJS = \ + $(OUT)\assert.obj \ $(OUT)\casestrcpy.obj \ $(OUT)\AFS_component_version_number.obj diff --git a/src/opr/assert.c b/src/opr/assert.c new file mode 100644 index 000000000..268ed938d --- /dev/null +++ b/src/opr/assert.c @@ -0,0 +1,15 @@ +#include +#include + +#include +#include "opr.h" + +#ifdef AFS_NT40_ENV +void +opr_NTAbort(void) +{ + DebugBreak(); +} +#endif + + diff --git a/src/opr/opr.h b/src/opr/opr.h index dacc70355..20a4e82f4 100644 --- a/src/opr/opr.h +++ b/src/opr/opr.h @@ -1,7 +1,14 @@ #ifndef OPENAFS_OPR_OPR_H #define OPENAFS_OPR_OPR_H 1 -/* casestrcpy.c */ +/* assert.c */ +#ifdef AFS_NT40_ENV +# define opr_abort() opr_NTAbort() +extern void opr_NTAbort(void); +#else +# define opr_abort() abort() +#endif + #define lcstring opr_lcstring #define ucstring opr_ucstring diff --git a/src/rx/rx_user.c b/src/rx/rx_user.c index 4e5742871..0ba9b7458 100644 --- a/src/rx/rx_user.c +++ b/src/rx/rx_user.c @@ -233,7 +233,7 @@ osi_Panic(char *msg, ...) va_end(ap); fflush(stderr); fflush(stdout); - afs_abort(); + opr_abort(); } /* diff --git a/src/rx/test/NTMakefile b/src/rx/test/NTMakefile index e3abf173e..3fa8ed5da 100644 --- a/src/rx/test/NTMakefile +++ b/src/rx/test/NTMakefile @@ -19,7 +19,8 @@ LIBS = \ $(DESTDIR)\lib\afs\mtafsutil.lib \ $(DESTDIR)\lib\afsrpc.lib \ $(DESTDIR)\lib\afspthread.lib \ - $(DESTDIR)\lib\afsroken.lib + $(DESTDIR)\lib\afsroken.lib \ + $(DESTDIR)\lib\opr.lib RXTESTOBJS = $(OUT)\testclient.obj $(OUT)\testserver.obj diff --git a/src/rx/test/testclient.c b/src/rx/test/testclient.c index 4a2978bbf..e06933ed1 100644 --- a/src/rx/test/testclient.c +++ b/src/rx/test/testclient.c @@ -27,6 +27,8 @@ #endif #include #include + +#include #include #include #include @@ -416,7 +418,7 @@ Abort(const char *msg, ...) rx_PrintStats(debugFile); fflush(debugFile); } - afs_abort(); + opr_abort(); exit(1); } diff --git a/src/rx/test/testserver.c b/src/rx/test/testserver.c index 12289196c..5780db308 100644 --- a/src/rx/test/testserver.c +++ b/src/rx/test/testserver.c @@ -28,6 +28,8 @@ #endif #include #include + +#include #include #include #include @@ -319,7 +321,7 @@ Abort(char *msg, ...) rx_PrintStats(debugFile); fflush(debugFile); } - afs_abort(); + opr_abort(); exit(1); } diff --git a/src/rxdebug/NTMakefile b/src/rxdebug/NTMakefile index 96bfeec96..21c44163d 100644 --- a/src/rxdebug/NTMakefile +++ b/src/rxdebug/NTMakefile @@ -25,7 +25,8 @@ RXDLIBS = $(LIBDIR)\afs\afscmd.lib \ $(LIBDIR)\afslwp.lib \ $(LIBDIR)\afs\afsutil.lib \ $(LIBDIR)\afs\afsreg.lib \ - $(LIBDIR)\afsroken.lib + $(LIBDIR)\afsroken.lib \ + $(LIBDIR)\opr.lib $(OUT)\rxdebug.res: rxdebug.rc $(VERSFILE).h $(RC) /Fo$*.RES $(*F).rc diff --git a/src/util/afsutil.h b/src/util/afsutil.h index 31bed6601..eef5c1cd2 100644 --- a/src/util/afsutil.h +++ b/src/util/afsutil.h @@ -57,14 +57,6 @@ extern int OpenLog(const char *filename); extern int ReOpenLog(const char *fileName); extern void SetupLogSignals(void); -/* abort the current process. */ -#ifdef AFS_NT40_ENV -#define afs_abort() afs_NTAbort() -#else -#define afs_abort() abort() -#endif - - #ifdef AFS_NT40_ENV #ifndef _MFC_VER #include @@ -77,8 +69,6 @@ extern void SetupLogSignals(void); /* Unbuffer output when Un*x would do line buffering. */ #define setlinebuf(S) setvbuf(S, NULL, _IONBF, 0) -/* Abort on error, possibly trapping to debugger or dumping a trace. */ - void afs_NTAbort(void); #endif /* AFS_NT40_ENV */ #ifndef HAVE_POSIX_REGEX diff --git a/src/util/assert.c b/src/util/assert.c index 197e1fdbf..0b51f11f8 100644 --- a/src/util/assert.c +++ b/src/util/assert.c @@ -12,17 +12,10 @@ #include #include +#include #include "afsutil.h" -#ifdef AFS_NT40_ENV -void -afs_NTAbort(void) -{ - DebugBreak(); -} -#endif - #define TIMESTAMP_BUFFER_SIZE 26 /* including the null */ void @@ -38,5 +31,5 @@ AssertionFailed(char *file, int line) fprintf(stderr, "%s Assertion failed! file %s, line %d.\n", tdate, file, line); fflush(stderr); - afs_abort(); + opr_abort(); } diff --git a/src/xstat/NTMakefile b/src/xstat/NTMakefile index 306187332..99eda7068 100644 --- a/src/xstat/NTMakefile +++ b/src/xstat/NTMakefile @@ -26,7 +26,8 @@ LIBS= \ $(LIBDIR)\afs\afspioctl.lib \ $(LIBDIR)\afs\afsutil.lib \ $(LIBDIR)\afs\afsreg.lib \ - $(LIBDIR)\afsroken.lib + $(LIBDIR)\afsroken.lib \ + $(LIBDIR)\opr.lib install: \ -- 2.39.5