OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [dl/] [dl-cache.h] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
2
   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
 
5
   The GNU C Library is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU Lesser General Public
7
   License as published by the Free Software Foundation; either
8
   version 2.1 of the License, or (at your option) any later version.
9
 
10
   The GNU C Library is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Lesser General Public License for more details.
14
 
15
   You should have received a copy of the GNU Lesser General Public
16
   License along with the GNU C Library; if not, write to the Free
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
   02111-1307 USA.  */
19
 
20
#include <stdint.h>
21
 
22
#ifndef _DL_CACHE_DEFAULT_ID
23
# define _DL_CACHE_DEFAULT_ID   3
24
#endif
25
 
26
#ifndef _dl_cache_check_flags
27
# define _dl_cache_check_flags(flags)                   \
28
  ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
29
#endif
30
 
31
#ifndef SYSCONFDIR
32
# define SYSCONFDIR "/etc"
33
#endif
34
 
35
#ifndef LD_SO_CACHE
36
# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
37
#endif
38
 
39
#define CACHEMAGIC "ld.so-1.7.0"
40
 
41
/* libc5 and glibc 2.0/2.1 use the same format.  For glibc 2.2 another
42
   format has been added in a compatible way:
43
   The beginning of the string table is used for the new table:
44
        old_magic
45
        nlibs
46
        libs[0]
47
        ...
48
        libs[nlibs-1]
49
        pad, new magic needs to be aligned
50
             - this is string[0] for the old format
51
        new magic - this is string[0] for the new format
52
        newnlibs
53
        ...
54
        newlibs[0]
55
        ...
56
        newlibs[newnlibs-1]
57
        string 1
58
        string 2
59
        ...
60
*/
61
struct file_entry
62
{
63
  int flags;            /* This is 1 for an ELF library.  */
64
  unsigned int key, value; /* String table indices.  */
65
};
66
 
67
struct cache_file
68
{
69
  char magic[sizeof CACHEMAGIC - 1];
70
  unsigned int nlibs;
71
  struct file_entry libs[0];
72
};
73
 
74
#define CACHEMAGIC_NEW "glibc-ld.so.cache"
75
#define CACHE_VERSION "1.1"
76
#define CACHEMAGIC_VERSION_NEW CACHEMAGIC_NEW CACHE_VERSION
77
 
78
 
79
struct file_entry_new
80
{
81
  int32_t flags;                /* This is 1 for an ELF library.  */
82
  uint32_t key, value;          /* String table indices.  */
83
  uint32_t osversion;           /* Required OS version.  */
84
  uint64_t hwcap;               /* Hwcap entry.  */
85
};
86
 
87
struct cache_file_new
88
{
89
  char magic[sizeof CACHEMAGIC_NEW - 1];
90
  char version[sizeof CACHE_VERSION - 1];
91
  uint32_t nlibs;               /* Number of entries.  */
92
  uint32_t len_strings;         /* Size of string table. */
93
  uint32_t unused[5];           /* Leave space for future extensions
94
                                   and align to 8 byte boundary.  */
95
  struct file_entry_new libs[0]; /* Entries describing libraries.  */
96
  /* After this the string table of size len_strings is found.  */
97
};
98
 
99
/* Used to align cache_file_new.  */
100
#define ALIGN_CACHE(addr)                               \
101
(((addr) + __alignof__ (struct cache_file_new) -1)      \
102
 & (~(__alignof__ (struct cache_file_new) - 1)))
103
 
104
static int
105
_dl_cache_libcmp (const char *p1, const char *p2)
106
{
107
  while (*p1 != '\0')
108
    {
109
      if (*p1 >= '0' && *p1 <= '9')
110
        {
111
          if (*p2 >= '0' && *p2 <= '9')
112
            {
113
              /* Must compare this numerically.  */
114
              int val1;
115
              int val2;
116
 
117
              val1 = *p1++ - '0';
118
              val2 = *p2++ - '0';
119
              while (*p1 >= '0' && *p1 <= '9')
120
                val1 = val1 * 10 + *p1++ - '0';
121
              while (*p2 >= '0' && *p2 <= '9')
122
                val2 = val2 * 10 + *p2++ - '0';
123
              if (val1 != val2)
124
                return val1 - val2;
125
            }
126
          else
127
            return 1;
128
        }
129
      else if (*p2 >= '0' && *p2 <= '9')
130
        return -1;
131
      else if (*p1 != *p2)
132
        return *p1 - *p2;
133
      else
134
        {
135
          ++p1;
136
          ++p2;
137
        }
138
    }
139
  return *p1 - *p2;
140
}

powered by: WebSVN 2.1.0

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