Skip to content

Commit

Permalink
kernel: remove some redundant #includes (#5885)
Browse files Browse the repository at this point in the history
... and add comments to a few others to explain why they
are needed
  • Loading branch information
fingolfin authored Jan 3, 2025
1 parent f580daf commit 6f1d1f0
Show file tree
Hide file tree
Showing 23 changed files with 32 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/bits_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "system.h"

#include <string.h>
#include <string.h> // for memcpy


#define ALL_BITS_UINT (~(UInt)0)
Expand Down
5 changes: 2 additions & 3 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@

#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#if defined(HAVE_BACKTRACE) && defined(GAP_PRINT_BACKTRACE)
#include <execinfo.h>
#include <signal.h>
#include <stdio.h> // for fprintf, fileno
#include <stdlib.h> // for exit

static void BacktraceHandler(int sig) NORETURN;

Expand Down
2 changes: 1 addition & 1 deletion src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "hpc/thread.h"
#endif

#include <stdio.h>
#include <stdio.h> // for fprintf


static Obj ErrorInner;
Expand Down
3 changes: 1 addition & 2 deletions src/funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
#ifdef HPCGAP
#include "hpc/guards.h"
#include "hpc/thread.h"
#include <stdlib.h> // for alloca
#endif

#include <stdlib.h>


static ModuleStateOffset FuncsStateOffset = -1;

Expand Down
5 changes: 2 additions & 3 deletions src/gvars.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@
#include "hpc/aobjects.h"
#include "hpc/guards.h"
#include "hpc/thread.h"
#include <pthread.h>
#endif

#include <stdio.h>


#ifdef HPCGAP
#define USE_GVAR_BUCKETS
Expand All @@ -59,6 +56,8 @@

#ifdef USE_GVAR_BUCKETS

#include <stdio.h> // for sprintf

#define GVAR_BUCKETS 1024
#define GVAR_BUCKET_SIZE 1024

Expand Down
2 changes: 1 addition & 1 deletion src/hookintrprtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "hpc/thread.h"

#include <string.h>
#include <string.h> // for memcpy


// List of active hooks
Expand Down
2 changes: 1 addition & 1 deletion src/hpc/aobjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "records.h"
#include "stringobj.h"

#include <stdlib.h>
#include <stdlib.h> // for labs


static Obj TYPE_ALIST;
Expand Down
4 changes: 2 additions & 2 deletions src/macfloat.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <stdio.h> // for snprintf
#include <stdlib.h> // for strtod


#define RequireMacFloat(funcname, op) \
Expand Down
6 changes: 3 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

#include "config.h"

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h> // for getenv, realpath, ...
#include <string.h> // for snprintf
#include <unistd.h> // for access, readlink, ...

#if defined(__APPLE__) && defined(__MACH__)
// Workaround: TRUE / FALSE are also defined by the macOS Mach-O headers
Expand Down
2 changes: 1 addition & 1 deletion src/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <dlfcn.h>
#endif

#include <stdio.h>
#include <stdio.h> // for fprintf, stderr


/****************************************************************************
Expand Down
6 changes: 2 additions & 4 deletions src/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@
#include "hpc/guards.h"
#include "hpc/thread.h"
#include "hpc/traverse.h"
#include <stdio.h> // for sprintf
#include <stdlib.h> // for getenv
#endif

#if defined(USE_THREADSAFE_COPYING)
#include "hpc/traverse.h"
#endif

#include <stdio.h>
#include <stdlib.h>


enum {
MAXPRINTDEPTH = 64,
};
Expand Down
2 changes: 0 additions & 2 deletions src/opers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ extern "C" {
#include <pthread.h>
#endif

#include <stdio.h>

#include "config.h"

} // extern "C"
Expand Down
2 changes: 1 addition & 1 deletion src/plist.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "objects.h"

#include <string.h>
#include <string.h> // for memcpy

/****************************************************************************
**
Expand Down
2 changes: 1 addition & 1 deletion src/precord.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "hpc/traverse.h"
#endif

#include <stdlib.h>
#include <stdlib.h> // for qsort

/****************************************************************************
**
Expand Down
6 changes: 3 additions & 3 deletions src/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

#include "config.h"

#include <stdio.h>
#include <stdio.h> // for fprintf, fflush, popen, pclose, fopen, fclose
#include <sys/time.h> // for gettimeofday
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h> // for pid_t
#include <unistd.h> // for getpid
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h> // definition of 'struct rusage'
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/stringobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "objects.h"

#include <string.h>
#include <string.h> // for memcpy


/****************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions src/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "hpc/thread.h"
#endif

#include <stdlib.h>


void InitSymbolTableKernel(SymbolTable * symtab,
const char * cookieCount,
Expand Down
2 changes: 1 addition & 1 deletion src/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "common.h"

#ifdef HPCGAP
#include <pthread.h>
#include <pthread.h> // for pthread_rwlock_t
#endif

// some auxiliary typedefs for SymbolTable
Expand Down
1 change: 0 additions & 1 deletion src/sysfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "records.h"
#include "stats.h"
#include "stringobj.h"
#include "sysenv.h"
#include "sysopt.h"
#include "sysstr.h"
#include "system.h"
Expand Down
10 changes: 6 additions & 4 deletions src/sysmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@

#ifdef GAP_MEM_CHECK
#include <fcntl.h>
#include <stdlib.h> // for qsort
#include <unistd.h> // for ftruncate, getpid, unlink
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h> // for fputs

#ifdef HAVE_MADVISE
#include <sys/mman.h>
#endif

#ifdef HAVE_VM_ALLOCATE
#include <mach/mach.h>
#elif defined(HAVE_SBRK)
#include <string.h> // for memset
#include <unistd.h> // for sbrk
#endif


Expand Down
2 changes: 1 addition & 1 deletion src/trans.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extern "C" {
#include "plist.h"
#include "saveload.h"

#include <stdio.h>
#include <stdio.h> // for snprintf

} // extern "C"

Expand Down
2 changes: 0 additions & 2 deletions src/trycatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include "gaputils.h"

#include <stdio.h>

static ThrowObserver throwObservers[16];

int RegisterThrowObserver(ThrowObserver func)
Expand Down
2 changes: 1 addition & 1 deletion src/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "hpc/guards.h"
#endif

#include <stdio.h>
#include <stdio.h> // for snprintf


/****************************************************************************
Expand Down

0 comments on commit 6f1d1f0

Please sign in to comment.