]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/getpagesize.c
[Ada] New pragma Aggregate_Individually_Assign
[thirdparty/gcc.git] / libiberty / getpagesize.c
CommitLineData
28e9041c 1/* Emulation of getpagesize() for systems that need it. */
2
3/*
4
a3a8a3df 5@deftypefn Supplemental int getpagesize (void)
28e9041c 6
614a23c6 7Returns the number of bytes in a page of memory. This is the
8granularity of many of the system memory management routines. No
9guarantee is made as to whether or not it is the same as the basic
10memory management hardware page size.
28e9041c 11
614a23c6 12@end deftypefn
28e9041c 13
14BUGS
15
16 Is intended as a reasonable replacement for systems where this
17 is not provided as a system call. The value of 4096 may or may
18 not be correct for the systems where it is returned as the default
19 value.
20
21*/
22
23#ifndef VMS
24
3c67ba63 25#include "config.h"
26
28e9041c 27#include <sys/types.h>
3c67ba63 28#ifdef HAVE_SYS_PARAM_H
28e9041c 29#include <sys/param.h>
30#endif
31
a18792d6 32#undef GNU_OUR_PAGESIZE
33#if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H)
28e9041c 34#include <unistd.h>
a18792d6 35#ifdef _SC_PAGESIZE
28e9041c 36#define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE)
a18792d6 37#endif
38#endif
39
40#ifndef GNU_OUR_PAGESIZE
41# ifdef PAGESIZE
42# define GNU_OUR_PAGESIZE PAGESIZE
43# else /* no PAGESIZE */
44# ifdef EXEC_PAGESIZE
45# define GNU_OUR_PAGESIZE EXEC_PAGESIZE
46# else /* no EXEC_PAGESIZE */
47# ifdef NBPG
48# define GNU_OUR_PAGESIZE (NBPG * CLSIZE)
49# ifndef CLSIZE
50# define CLSIZE 1
51# endif /* CLSIZE */
52# else /* no NBPG */
53# ifdef NBPC
54# define GNU_OUR_PAGESIZE NBPC
55# else /* no NBPC */
56# define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */
57# endif /* NBPC */
58# endif /* NBPG */
59# endif /* EXEC_PAGESIZE */
60# endif /* PAGESIZE */
61#endif /* GNU_OUR_PAGESIZE */
28e9041c 62
63int
8858115e 64getpagesize (void)
28e9041c 65{
66 return (GNU_OUR_PAGESIZE);
67}
68
69#else /* VMS */
70
71#if 0 /* older distributions of gcc-vms are missing <syidef.h> */
72#include <syidef.h>
73#endif
74#ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */
75#define SYI$_PAGE_SIZE 4452
76#endif
77extern unsigned long lib$getsyi(const unsigned short *,...);
78
8858115e 79int getpagesize (void)
28e9041c 80{
81 long pagsiz = 0L;
82 unsigned short itmcod = SYI$_PAGE_SIZE;
83
84 (void) lib$getsyi (&itmcod, (void *) &pagsiz);
85 if (pagsiz == 0L)
86 pagsiz = 512L; /* VAX default */
87 return (int) pagsiz;
88}
89
90#endif /* VMS */