Move abort() into opr
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 11 Sep 2011 20:44:23 +0000 (21:44 +0100)
committerDerrick Brashear <shadow@dementix.org>
Mon, 26 Sep 2011 04:09:54 +0000 (21:09 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

16 files changed:
src/WINNT/client_exp/NTMakefile
src/lwp/iomgr.c
src/lwp/lwp.h
src/lwp/lwp_nt.c
src/opr/Makefile.in
src/opr/NTMakefile
src/opr/assert.c [new file with mode: 0644]
src/opr/opr.h
src/rx/rx_user.c
src/rx/test/NTMakefile
src/rx/test/testclient.c
src/rx/test/testserver.c
src/rxdebug/NTMakefile
src/util/afsutil.h
src/util/assert.c
src/xstat/NTMakefile

index e7c9830..31f33be 100644 (file)
@@ -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)
index b0148ea..2ed325a 100644 (file)
 
 #include <roken.h>
 
-#ifdef AFS_NT40_ENV
-extern void lwp_abort(void);
-#endif /* AFS_NT40_ENV */
-
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
 
+#include <afs/opr.h>
+
 #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
 
index a94209e..3b58c59 100644 (file)
@@ -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 */
 
index 147a91a..c37baeb 100644 (file)
@@ -22,6 +22,7 @@
 #include <roken.h>
 
 #ifdef AFS_NT40_ENV
+#include <afs/opr.h>
 #include <afs/afsutil.h>
 #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"))
index d339cfc..566cdbe 100644 (file)
@@ -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 $@
index 6784827..a10ee52 100644 (file)
@@ -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 (file)
index 0000000..268ed93
--- /dev/null
@@ -0,0 +1,15 @@
+#include <afsconfig.h>
+#include <afs/param.h>
+
+#include <roken.h>
+#include "opr.h"
+
+#ifdef AFS_NT40_ENV
+void
+opr_NTAbort(void)
+{
+    DebugBreak();
+}
+#endif
+
+
index dacc703..20a4e82 100644 (file)
@@ -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
index 4e57428..0ba9b74 100644 (file)
@@ -233,7 +233,7 @@ osi_Panic(char *msg, ...)
     va_end(ap);
     fflush(stderr);
     fflush(stdout);
-    afs_abort();
+    opr_abort();
 }
 
 /*
index e3abf17..3fa8ed5 100644 (file)
@@ -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
index 4a2978b..e06933e 100644 (file)
@@ -27,6 +27,8 @@
 #endif
 #include <sys/stat.h>
 #include <signal.h>
+
+#include <afs/opr.h>
 #include <rx/rx_clock.h>
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
@@ -416,7 +418,7 @@ Abort(const char *msg, ...)
        rx_PrintStats(debugFile);
        fflush(debugFile);
     }
-    afs_abort();
+    opr_abort();
     exit(1);
 }
 
index 1228919..5780db3 100644 (file)
@@ -28,6 +28,8 @@
 #endif
 #include <signal.h>
 #include <sys/stat.h>
+
+#include <afs/opr.h>
 #include <rx/rx_clock.h>
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
@@ -319,7 +321,7 @@ Abort(char *msg, ...)
        rx_PrintStats(debugFile);
        fflush(debugFile);
     }
-    afs_abort();
+    opr_abort();
     exit(1);
 }
 
index 96bfeec..21c4416 100644 (file)
@@ -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 
index 31bed66..eef5c1c 100644 (file)
@@ -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 <winsock2.h>
@@ -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
index 197e1fd..0b51f11 100644 (file)
 #include <afs/param.h>
 
 #include <roken.h>
+#include <afs/opr.h>
 
 #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();
 }
index 3061873..99eda70 100644 (file)
@@ -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: \