OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [libiberty/] [getpagesize.c] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.