File: getpagesize.c

package info (click to toggle)
gdb 8.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 223,696 kB
  • sloc: ansic: 1,936,156; asm: 341,757; exp: 146,606; makefile: 56,749; sh: 23,776; cpp: 20,830; yacc: 12,914; perl: 5,331; ada: 4,977; python: 4,617; xml: 4,176; pascal: 3,134; lisp: 1,527; cs: 879; lex: 620; f90: 479; sed: 228; awk: 140; objc: 134; fortran: 43
file content (90 lines) | stat: -rw-r--r-- 2,066 bytes parent folder | download | duplicates (75)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* Emulation of getpagesize() for systems that need it. */

/*

@deftypefn Supplemental int getpagesize (void)

Returns the number of bytes in a page of memory.  This is the
granularity of many of the system memory management routines.  No
guarantee is made as to whether or not it is the same as the basic
memory management hardware page size.

@end deftypefn

BUGS

	Is intended as a reasonable replacement for systems where this
	is not provided as a system call.  The value of 4096 may or may
	not be correct for the systems where it is returned as the default
	value.

*/

#ifndef VMS

#include "config.h"

#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif

#undef GNU_OUR_PAGESIZE
#if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H)
#include <unistd.h>
#ifdef _SC_PAGESIZE
#define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE)
#endif
#endif

#ifndef GNU_OUR_PAGESIZE
# ifdef	PAGESIZE
#  define	GNU_OUR_PAGESIZE PAGESIZE
# else	/* no PAGESIZE */
#  ifdef	EXEC_PAGESIZE
#   define	GNU_OUR_PAGESIZE EXEC_PAGESIZE
#  else	/* no EXEC_PAGESIZE */
#   ifdef	NBPG
#    define	GNU_OUR_PAGESIZE (NBPG * CLSIZE)
#    ifndef	CLSIZE
#     define	CLSIZE 1
#    endif	/* CLSIZE */
#   else	/* no NBPG */
#    ifdef	NBPC
#     define	GNU_OUR_PAGESIZE NBPC
#    else	/* no NBPC */
#     define	GNU_OUR_PAGESIZE 4096	/* Just punt and use reasonable value */
#    endif /* NBPC */
#   endif /* NBPG */
#  endif /* EXEC_PAGESIZE */
# endif /* PAGESIZE */
#endif /* GNU_OUR_PAGESIZE */

int
getpagesize (void)
{
  return (GNU_OUR_PAGESIZE);
}

#else /* VMS */

#if 0	/* older distributions of gcc-vms are missing <syidef.h> */
#include <syidef.h>
#endif
#ifndef SYI$_PAGE_SIZE	/* VMS V5.4 and earlier didn't have this yet */
#define SYI$_PAGE_SIZE 4452
#endif
extern unsigned long lib$getsyi(const unsigned short *,...);

int getpagesize (void)
{
  long pagsiz = 0L;
  unsigned short itmcod = SYI$_PAGE_SIZE;

  (void) lib$getsyi (&itmcod, (void *) &pagsiz);
  if (pagsiz == 0L)
    pagsiz = 512L;	/* VAX default */
  return (int) pagsiz;
}

#endif /* VMS */