From 4a3108e5e769a77b8bc7155127052ed3b22c0163 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 6 May 2019 15:21:16 +0200 Subject: [PATCH] libgap-api: clang-format, adjust some comments --- src/libgap-api.c | 6 +++--- src/libgap-api.h | 53 +++++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/libgap-api.c b/src/libgap-api.c index 38889931ba..af1c7b9866 100644 --- a/src/libgap-api.c +++ b/src/libgap-api.c @@ -423,8 +423,7 @@ void GAP_LeaveStack_(void) void GAP_EnterDebugMessage_(char * message, char * file, int line) { - fprintf(stderr, "%s: %d; %s:%d\n", message, EnterStackCount, file, - line); + fprintf(stderr, "%s: %d; %s:%d\n", message, EnterStackCount, file, line); } int GAP_Error_Prejmp_(const char * file, int line) @@ -437,7 +436,8 @@ int GAP_Error_Prejmp_(const char * file, int line) } /* Helper function for GAP_Error_Postjmp_ (see libgap-api.h) which manipulates - * EnterStackCount in the (generally unlikely) case of returning from a longjmp + * EnterStackCount in the (generally unlikely) case of returning from a + * longjmp */ void GAP_Error_Postjmp_Returning_(void) { diff --git a/src/libgap-api.h b/src/libgap-api.h index 650d265bfd..a42c57e207 100644 --- a/src/libgap-api.h +++ b/src/libgap-api.h @@ -32,7 +32,7 @@ extern syJmp_buf * GAP_GetReadJmpError(void); extern void GAP_EnterDebugMessage_(char * message, char * file, int line); extern void GAP_EnterStack_(void *); extern void GAP_LeaveStack_(void); -extern int GAP_Error_Prejmp_(const char *, int); +extern int GAP_Error_Prejmp_(const char *, int); extern void GAP_Error_Postjmp_Returning_(void); @@ -63,14 +63,15 @@ static inline int GAP_Error_Postjmp_(int JumpRet) // collector; otherwise GAP objects may be garbage collected while still in // use. // -// In general user code should use the more general GAP_Enter()/Leave() macros -// defined below, as these also specify a terminal point for unhandled GAP -// errors to bubble up to. However, GAP_EnterStack() and GAP_LeaveStack() -// should still be used in the defintion of a custom error handling callback as -// passed to GAP_Initialize(). Using the more general GAP_Enter() in this case -// will result in crashes if the error handler is entered recursively (you -// don't want the GAP error handling code to cause a longjmp into the error -// callback itself since then the error callback will never be returned from). +// In general user code should use the more general GAP_Enter()/Leave() +// macros defined below, as these also specify a terminal point for unhandled +// GAP errors to bubble up to. However, GAP_EnterStack() and +// GAP_LeaveStack() should still be used in the definition of a custom error +// handling callback as passed to GAP_Initialize(). Using the more general +// GAP_Enter() in this case will result in crashes if the error handler is +// entered recursively (you don't want the GAP error handling code to cause a +// longjmp into the error callback itself since then the error callback will +// never be returned from). #ifdef __GNUC__ #define GAP_EnterStack() \ do { \ @@ -92,8 +93,7 @@ static inline int GAP_Error_Postjmp_(int JumpRet) } while (0) #endif -#define GAP_LeaveStack() \ - GAP_LeaveStack_(); +#define GAP_LeaveStack() GAP_LeaveStack_(); #define GAP_Error_Setjmp() \ @@ -101,21 +101,22 @@ static inline int GAP_Error_Postjmp_(int JumpRet) GAP_Error_Postjmp_(sySetjmp(*GAP_GetReadJmpError()))) -// Code which uses the GAP API exposed by this header file should sandwich any -// such calls between uses of the GAP_Enter() and GAP_Leave() macro as follows: -// +// Code which uses the GAP API exposed by this header file should sandwich +// any such calls between uses of the GAP_Enter() and GAP_Leave() macro as +// follows: +// // int ok = GAP_Enter(); // if (ok) { // ... // any number of calls to GAP APIs // } // GAP_Leave(); -// +// // This is in particular crucial if your code keeps references to any GAP -// functions in local variables: Calling GAP_Enter() ensures that GAP is aware -// of such references, and will not garbage collect the referenced objects. -// Failing to use these macros properly can lead to crashes, or worse, silent -// memory corruption. You have been warned! -// +// functions in local variables: Calling GAP_Enter() ensures that GAP is +// aware of such references, and will not garbage collect the referenced +// objects. Failing to use these macros properly can lead to crashes, or +// worse, silent memory corruption. You have been warned! +// // Note that due to the implementation of these macros, you unfortunately // cannot "simplify" the above example code to: // @@ -129,14 +130,14 @@ static inline int GAP_Error_Postjmp_(int JumpRet) // is the return value of GAP_Error_Setjmp). // // * GAP_EnterStack() defined and explained above must be a macro since it -// needs to figure out (to the extent possible) the base address of the stack -// frame from which it is called. +// needs to figure out (to the extent possible) the base address of the +// stack frame from which it is called. // // * GAP_Error_Setjmp() effectively calls setjmp to the STATE(ReadJmpError) // longjmp buffer, so that read errors which occur in GAP that are not // otherwise "handled" by a TRY_IF_NO_ERROR { } block have a logical place -// to return to. It returns 1 if no error occurred, and 0 if returning from -// an error. +// to return to. It returns 1 if no error occurred, and 0 if returning +// from an error. #define GAP_Enter() \ GAP_Error_Setjmp(); \ GAP_EnterStack() @@ -327,8 +328,9 @@ Obj GAP_ElmList(Obj list, UInt pos); // Returns a new empty plain list with capacity Obj GAP_NewPlist(Int capacity); + //// -//// Records +//// records //// // Returns 1 if is a GAP record, 0 if not. @@ -347,6 +349,7 @@ Obj GAP_ElmRecord(Obj rec, Obj name); // Returns a new empty plain record with capacity . Obj GAP_NewPrecord(Int capacity); + //// //// strings ////