Libc_r.so.4 download




















The names of all library types, macros, variables and functions that come from the ISO C standard are reserved unconditionally; your program may not redefine these names. All other library names are reserved if your program explicitly includes the header file that defines or declares them.

There are several reasons for these restrictions:. This is so that the library and header files can define functions, variables, and macros for internal purposes without risk of conflict with names in user programs. While using these names for your own purposes right now might not cause a problem, they do raise the possibility of conflict with future versions of the C or POSIX standards, so you should avoid these names.

In addition, some individual header files reserve names beyond those that they actually define. You only need to worry about these restrictions if your program includes that particular header file. The exact set of features available when you compile a source file is controlled by which feature test macros you define. These directives must come before any include of a system header file. It is best to make them the very first thing in the file, preceded only by comments.

This system exists to allow the library to conform to multiple standards. Although the different standards are often described as supersets of each other, they are usually incompatible because larger standards require functions with names that smaller ones reserve to the user program. This is not mere pedantry — it has been a problem in practice. They would not be compilable if all features were enabled indiscriminately. This should not be used to verify that a program conforms to a limited standard.

It is insufficient for this purpose, as it will not protect you from including header files outside the standard, or relying on semantics undefined within the standard. The greater the value of this macro, the more functionality is made available. If you define this macro to a value greater than or equal to 1 , then the functionality from the edition of the POSIX.

If you define this macro to a value greater than or equal to 2 , then the functionality from the edition of the POSIX. If you define this macro to a value greater than or equal to L , then the functionality from the edition of the POSIX. In general, in the GNU C Library, bugfixes to the standards are included when specifying the base version; e.

The value corresponding to the sixth revision includes definitions from SUSv3, and using the seventh revision includes definitions from SUSv4. If this macro is defined some extra functions are available which rectify a few shortcomings in all previous standards. Specifically, the functions fseeko and ftello are available. If you define this macro an additional set of functions is made available which enables 32 bit systems to use files of sizes beyond the usual limit of 2GB.

This interface is not available if the system does not support files that large. On systems where the natural file size limit is greater than 2GB i. The new functionality is made available by a new set of types and functions which replace the existing ones.

The names of these new objects contain 64 to indicate the intention, e. This macro determines which file system interface shall be used, one replacing the other. If the macro is defined to the value 64 , the large file interface replaces the old interface. Instead the old function names now reference the new functions, e. This macro should only be selected if the system provides mechanisms for handling large files.

By using this macro certain ports gain support for bit time and as a result become immune to the Y problem. If this macro is defined, features from ISO C99 are included. Since these features are included by default, this macro is mostly relevant when the compiler uses an earlier language version. This affects declarations of the totalorder functions and functions related to NaN payloads.

If this macro is defined to 1 , security hardening is added to various library functions. If defined to 2 , even stricter checks are applied. If defined to 3 , the GNU C Library may also use checks that may have an additional performance overhead. These macros are obsolete. Some very old C libraries required one of these macros to be defined for basic functionality e.

When you define a feature test macro to request a larger class of features, it is harmless to define in addition a feature test macro for a subset of those features. If you already know the name of the facility you are interested in, you can look it up in Library Summary. This gives you a summary of its syntax and a pointer to where you can find a more detailed description. This appendix is particularly useful if you just want to verify the order and type of arguments to a function, for example.

It also tells you what standard or system each function, variable, or macro is derived from. Many functions in the GNU C Library detect and report error conditions, and sometimes your programs need to check for these error conditions. For example, when you open an input file, you should verify that the file was actually opened correctly, and print an error message or take other appropriate action if the call to the library function failed. This chapter describes how the error reporting facility works.

Your program should include the header file errno. Most library functions return a special value to indicate that they have failed. The special value is typically -1 , a null pointer, or a constant such as EOF that is defined for that purpose.

But this return value tells you only that an error has occurred. To find out what kind of error it was, you need to look at the error code stored in the variable errno. This variable is declared in the header file errno. The variable errno contains the system error number. You can change the value of errno. Since errno is declared volatile , it might be changed asynchronously by a signal handler; see Defining Handlers.

However, a properly written signal handler saves and restores the value of errno , so you generally do not need to worry about this possibility except when writing signal handlers. The initial value of errno at program startup is zero. In many cases, when a library function encounters an error, it will set errno to a non-zero value to indicate what specific error condition occurred. The documentation for each function lists the error conditions that are possible for that function.

Not all library functions use this mechanism; some return an error code directly, instead. Warning: Many library functions may set errno to some meaningless non-zero value even if they did not encounter any errors, and even if they return error codes directly. Therefore, it is usually incorrect to check whether an error occurred by inspecting the value of errno. The proper way to check for error is documented for each function.

There are a few library functions, like sqrt and atan , that return a perfectly legitimate value in case of an error, but also set errno. For these functions, if you want to check to see whether an error occurred, the recommended method is to set errno to zero before calling the function, and then check its value afterward. All the error codes have symbolic names; they are macros defined in errno.

See Reserved Names. Your program should not make any other assumptions about the specific values of these symbolic constants.

The only values that are guaranteed to be meaningful for a particular library function are the ones that this manual lists for that function. In some Unix systems, many system calls can also return EFAULT if given as an argument a pointer into the stack, and the kernel for some obscure reason fails in its attempt to extend the stack.

If this ever happens, you should probably try using statically or dynamically allocated memory instead of stack memory on that system.

The error code macros are defined in the header file errno. All of them expand into integer constant values. When this happens, you should try the call again. This can mean that the device file was installed incorrectly, or that the physical device is missing or not correctly attached to the computer.

This condition is detected by the exec functions; see Executing a File. The system does not guarantee that it will notice all such situations. This error means you got lucky and the system noticed; it might just hang. See File Locks , for an example. For example, trying to mount an ordinary file as a file system in Unix gives this error. For example, if you try to delete a file that is the root of a currently mounted filesystem, you get this error.

This happens not only when you use link see Hard Links but also when you rename a file with rename see Renaming Files. Duplicate descriptors do count toward this limit. Note that any number of linked channels count as just one file opening; see Linked Channels. Often using a debugger to run a program is considered having it open for writing and will cause this error. Every library function that returns this error code also generates a SIGPIPE signal; this signal terminates the program if not handled or blocked.

To make your program portable, you should check for both codes and treat them the same. The values are always the same, on every operating system. See Socket Options. See Creating a Socket. See Sockets. See Socket Addresses.

See Connecting. You get this error when you try to transmit data over a socket, without first specifying a destination for the data. You get this error when you try to transmit data over a connectionless socket, without first specifying a destination for the data with connect.

This often indicates a cycle of symbolic links. Typically, this error occurs when you are trying to delete a directory. Repairing this condition usually requires unmounting, possibly repairing and remounting the file system.

On some systems chmod returns this error if you try to set the sticky bit on a non-directory file; see Setting Permissions. When you get this error, you can be sure that this particular function will always fail with ENOSYS unless you install a new version of the C library or the operating system. This can mean that the function does not implement a particular command or option value or flag bit at all. For functions that operate on some object given in a parameter, such as a file descriptor or a port, it might instead mean that only that specific object file descriptor, port, etc.

See Job Control , for information on process groups and these signals. They are not yet documented. The library has functions and variables designed to make it easy for your program to report informative error messages in the customary format about the failure of a library call. The strerror function maps the error code see Checking for Errors specified by the errnum argument to a descriptive error message string.

The return value is a pointer to this string. You should not modify the string returned by strerror. Also, if you make subsequent calls to strerror , the string might be overwritten. This might be either some permanent global data or a message string in the user supplied buffer starting at buf with the length of n bytes. At most n characters are written including the NUL byte so it is up to the user to select a buffer large enough.

This function should always be used in multi-threaded programs since there is no way to guarantee the string returned by strerror really belongs to the last call of the current thread. This function prints an error message to the stream stderr ; see Standard Streams.

The orientation of stderr is not changed. If you call perror with a message that is either a null pointer or an empty string, perror just prints the error message corresponding to errno , adding a trailing newline.

If you supply a non-null message argument, then perror prefixes its output with this string. It adds a colon and a space character to separate the message from the error string corresponding to errno. This function returns the name describing the error errnum or NULL if there is no known constant with this value e. This function returns the message describing the error errnum or NULL if there is no known constant with this value e.

Different than strerror the returned description is not translated. With the GNU C Library, the messages are fairly short; there are no multi-line messages or embedded newlines. Each error message begins with a capital letter and does not include any terminating punctuation. It is the same as argv[0]. Note that this is not necessarily a useful file name; often it contains no directory names.

See Program Arguments. The library initialization code sets up both of these variables before calling main. Portability Note: If you want your program to work with non-GNU libraries, you must save the value of argv[0] in main , and then strip off the directory names yourself. We added these extensions to make it possible to write self-contained error-reporting subroutines that require no explicit cooperation from main. Here is an example showing how to handle failure to open a file correctly.

Using perror has the advantage that the function is portable and available on all systems implementing ISO C. But often the text perror generates is not what is wanted and there is no way to extend or change what perror does. The GNU coding standard, for instance, requires error messages to be preceded by the program name and programs which read some input files should provide information about the input file name and the line number in case an error is encountered while reading the file.

For these occasions there are two functions available which are widely used throughout the GNU project. These functions are declared in error. The error function can be used to report general problems during program execution. The format argument is a format string just like those given to the printf family of functions. The arguments required for the format can follow the format parameter.

Just like perror , error also can report an error code in textual form. But unlike perror the error value is explicitly passed to the function in the errnum parameter. This eliminates the problem mentioned above that the error reporting function must be called immediately after the function causing the error since otherwise errno might have a different value.

The program name is followed by a colon and a space which in turn is followed by the output produced by the format string. If the errnum parameter is non-zero the format string output is followed by a colon and a space, followed by the error message for the error code errnum. In any case is the output terminated with a newline.

The output is directed to the stderr stream. The function will return unless the status parameter has a non-zero value. In this case the function will call exit with the status value for its parameter and therefore never return. The only differences are the additional parameters fname and lineno. The handling of the other parameters is identical to that of error except that between the program name and the string generated by the format string additional text is inserted.

Directly following the program name a colon, followed by the file name pointed to by fname , another colon, and the value of lineno is printed. This additional output of course is meant to be used to locate an error in an input file like a programming language source code file etc.

Repetition which are not directly following each other are not caught. Just like error this function only returns if status is zero. Otherwise exit is called with the non-zero value. It is expected to print the program name or do something similarly useful. The function is expected to print to the stderr stream and must be able to handle whatever orientation the stream has.

The variable is global and shared by all threads. This variable is global and shared by all threads. These functions are declared in err. It is generally advised to not use these functions. They are included only for compatibility. The difference to warn is that no error number string is printed.

The difference to err is that no error number string is printed. They vary in generality and in efficiency. The library also provides functions for controlling paging and allocation of real memory. One of the most basic resources a process has available to it is memory. There are a lot of different ways systems organize memory, but in a typical one, each process has one linear virtual address space, with addresses running from zero to some huge maximum.

It need not be contiguous; i. The virtual memory is divided into pages 4 kilobytes is typical. Backing each page of virtual memory is a page of real memory called a frame or some secondary storage, usually disk space.

The disk space might be swap space or just some ordinary disk file. The same frame of real memory or backing store can back multiple virtual pages belonging to multiple processes. The same real memory frame containing the printf function backs a virtual memory page in each of the existing processes that has a printf call in its program.

But because there is usually a lot more virtual memory than real memory, the pages must move back and forth between real memory and backing store regularly, coming into real memory when a process needs to access them and then retreating to backing store when not needed anymore. This movement is called paging. When a program attempts to access a page which is not at that moment backed by real memory, this is known as a page fault. In fact, to the process, all pages always seem to be in real memory.

For programs sensitive to that, the functions described in Locking Pages can control it. Within each virtual address space, a process has to keep track of what is at which addresses, and that process is called memory allocation. Processes allocate memory in two major ways: by exec and programmatically. See Creating a Process. Exec is the operation of creating a virtual address space for a process, loading its basic program into it, and executing the program.

The operation takes a program file an executable , it allocates space to load all the data in the executable, loads it, and transfers control to it. That data is most notably the instructions of the program the text , but also literals and constants in the program and even some variables: C variables with the static storage class see Memory Allocation and C. Once that program begins to execute, it uses programmatic allocation to gain additional memory.

See Memory Allocation and C. The system makes the virtual memory initially contain the contents of the file, and if you modify the memory, the system writes the same modification to the file. Just as it programmatically allocates memory, the program can programmatically deallocate free it.

When the program exits or execs, you might say that all its memory gets freed, but since in both cases the address space ceases to exist, the point is really moot. See Program Termination. A segment is a contiguous range of virtual addresses. Three important segments are:. This section covers how ordinary programs manage storage for their data, including the famous malloc function and some fancier facilities special to the GNU C Library and GNU Compiler.

In GNU C, the size of the automatic storage can be an expression that varies. In other C implementations, it must be a constant. A third important kind of memory allocation, dynamic allocation , is not supported by C variables but is available via GNU C Library functions.

Dynamic memory allocation is a technique in which programs determine as they are running where to store some information. You need dynamic allocation when the amount of memory you need, or how long you continue to need it, depends on factors that are not known before the program runs.

For example, you may need a block to store a line read from an input file; since there is no limit to how long a line can be, you must allocate the memory dynamically and make it dynamically larger as you read more of the line. When you use dynamic allocation, the allocation of a block of memory is an action that the program requests explicitly.

You call a function or macro when you want to allocate space, and specify the size with an argument. If you want to free the space, you do so by calling another function or macro. You can do these things whenever you want, as often as you want. The only way to get dynamically allocated memory is via a system call which is generally via a GNU C Library function call , and the only way to refer to dynamically allocated space is through a pointer.

Because it is less convenient, and because the actual process of dynamic allocation requires more computation time, programmers generally use dynamic allocation only when neither static nor automatic allocation will serve.

For example, if you want to allocate dynamically some space to hold a struct foobar , you cannot declare a variable of type struct foobar whose contents are the dynamically allocated space. The malloc implementation in the GNU C Library is derived from ptmalloc pthreads malloc , which in turn is derived from dlmalloc Doug Lea malloc. This malloc may allocate memory in two different ways depending on their size and certain parameters that may be controlled by users.

The most common way is to allocate portions of memory called chunks from a large contiguous area of memory and manage these areas to optimize their use and reduce wastage in the form of unusable chunks.

Traditionally the system heap was set up to be the one large memory area but the GNU C Library malloc implementation maintains multiple such areas to optimize their use in multi-threaded applications. Each such area is internally referred to as an arena. As opposed to other versions, the malloc in the GNU C Library does not round up chunk sizes to powers of two, neither for large nor for small sizes.

Neighboring chunks can be coalesced on a free no matter what their size is. This makes the implementation suitable for all kinds of allocation patterns without generally incurring high memory waste through fragmentation. The presence of multiple arenas allows multiple threads to allocate memory simultaneously in separate arenas, thus improving performance.

The other way of memory allocation is for very large blocks, i. This has the great advantage that these chunks are returned to the system immediately when they are freed. The size threshold for mmap to be used is dynamic and gets adjusted according to allocation patterns of the program.

It is possible to use your own custom malloc instead of the built-in allocator provided by the GNU C Library. See Replacing malloc. The most general dynamic allocation facility is malloc. It allows you to allocate blocks of memory of any size at any time, make them bigger or smaller at any time, and free the blocks individually at any time or never.

To allocate a block of memory, call malloc. The prototype for this function is in stdlib. This function returns a pointer to a newly allocated block size bytes long, or a null pointer setting errno if the block could not be allocated. The contents of the block are undefined; you must initialize it yourself or use calloc instead; see Allocating Cleared Space.

Normally you would convert the value to a pointer to the kind of object that you want to store in the block. Here we show an example of doing so, and of initializing the space with zeros using the library function memset see Copying Strings and Arrays :.

However, a cast is necessary if the type is needed but not specified by context. Remember that when allocating space for a string, the argument to malloc must be one plus the length of the string. For example:. See Representation of Strings , for more information about this.

If no more space is available, malloc returns a null pointer. You should check the value of every call to malloc. It is useful to write a subroutine that calls malloc and reports an error if the value is a null pointer, returning only if the value is nonzero. This function is conventionally called xmalloc. Here it is:.

Here is a real example of using malloc by way of xmalloc. The function savestring will copy a sequence of characters into a newly allocated null-terminated string:. The block that malloc gives you is guaranteed to be aligned so that it can hold any type of data. On GNU systems, the address is always a multiple of eight on bit systems, and a multiple of 16 on bit systems. Note that the memory located after the end of the block is likely to be in use for something else; perhaps a block already allocated by another call to malloc.

If you attempt to treat the block as longer than you asked for it to be, you are liable to destroy the data that malloc uses to keep track of its blocks, or you may destroy the contents of another block.

If you have already allocated a block and discover you want it to be bigger, use realloc see Changing Block Size. When you no longer need a block that you got with malloc , use the function free to make the block available to be allocated again.

Freeing a block alters the contents of the block. Do not expect to find any data such as a pointer to the next block in a chain of blocks in the block after freeing it. Copy whatever you need out of the block before freeing it! Here is an example of the proper way to free all the blocks in a chain, and the strings that they point to:. Occasionally, free can actually return memory to the operating system and make the process smaller.

Usually, all it can do is allow a later call to malloc to reuse the space. In the meantime, the space remains in your program as part of a free-list used internally by malloc. The free function preserves the value of errno , so that cleanup code need not worry about saving and restoring errno around a call to free.

Often you do not know for certain how big a block you will ultimately need at the time you must begin to use the block. For example, the block might be a buffer that you use to hold a line being read from a file; no matter how long you make the buffer initially, you may encounter a line that is longer.

You can make the block longer by calling realloc or reallocarray. These functions are declared in stdlib. The realloc function changes the size of the block whose address is ptr to be newsize.

Since the space after the end of the block may be in use, realloc may find it necessary to copy the block to a new address where more free space is available. The value of realloc is the new address of the block.

If the block needs to be moved, realloc copies the old contents. Otherwise, if newsize is zero realloc frees the block and returns NULL. Otherwise, if realloc cannot reallocate the requested size it returns NULL and sets errno ; the original block is left undisturbed. The reallocarray function changes the size of the block whose address is ptr to be long enough to contain a vector of nmemb elements, each of size size. Portability Note: This function is not part of any standard.

It was first introduced in OpenBSD 5. Like malloc , realloc and reallocarray may return a null pointer if no memory space is available to make the block bigger. When this happens, the original block is untouched; it has not been modified or relocated. In most cases it makes no difference what happens to the original block when realloc fails, because the application program cannot continue when it is out of memory, and the only thing to do is to give a fatal error message.

Often it is convenient to write and use subroutines, conventionally called xrealloc and xreallocarray , that take care of the error message as xmalloc does for malloc :. You can also use realloc or reallocarray to make a block smaller. The reason you would do this is to avoid tying up a lot of memory space when only a little is needed. In several allocation implementations, making a block smaller sometimes necessitates copying it, so it can fail if no other space is available.

The function calloc allocates memory and clears it to zero. It is declared in stdlib. This function allocates a block long enough to contain a vector of count elements, each of size eltsize. Its contents are cleared to zero before calloc returns.

But in general, it is not guaranteed that calloc calls reallocarray and memset internally. For example, if the calloc implementation knows for other reasons that the new memory block is zero, it need not zero out the block again with memset. Also, if an application provides its own reallocarray outside the C library, calloc might not use that redefinition. The address of a block returned by malloc or realloc in GNU systems is always a multiple of eight or sixteen on bit systems.

The alignment must be a power of two and size must be a multiple of alignment. The memalign function allocates a block of size bytes whose address is a multiple of boundary. The boundary must be a power of two! The function memalign works by allocating a somewhat larger block, and then returning an address within the block that is on the specified boundary. The memalign function returns a null pointer on error and sets errno to one of the following values:. Otherwise the function returns an error value indicating the problem.

The possible error values returned are:. Using valloc is like using memalign and passing the page size as the value of the first argument. It is implemented like this:. Query Memory Parameters for more information about the memory subsystem. You can adjust some parameters for dynamic memory allocation with the mallopt function.

When calling mallopt , the param argument specifies the parameter to be set, and value the new value to be set. Possible choices for param , as defined in malloc. The maximum number of chunks to allocate with mmap. Setting this to zero disables all use of mmap. All chunks larger than this value are allocated outside the normal heap, using the mmap system call.

This way it is guaranteed that the memory for these chunks can be returned to the system on free. Note that requests smaller than this threshold might still be allocated via mmap.

If this parameter is not set, the default value is set as KiB and the threshold is adjusted dynamically to suit the allocation patterns of the program. If the parameter is set, the dynamic adjustment is disabled and the value is set statically to the input value.

If non-zero, memory blocks are filled with values depending on some low order bits of this parameter when they are allocated except when allocated by calloc and freed. This can be used to debug the use of uninitialized or freed heap memory.

Note that this option does not guarantee that the freed block will have any specific values. It only guarantees that the content the block had before it was freed will be overwritten. This parameter determines the amount of extra memory to obtain from the system when an arena needs to be extended. It also specifies the number of bytes to retain when shrinking an arena. This provides the necessary hysteresis in heap size such that excessive amounts of system calls can be avoided.

This is the minimum size in bytes of the top-most, releasable chunk that will trigger a system call in order to return memory to the system. If the parameter is set, the dynamic adjustment is disabled and the value is set statically to the provided input. This parameter specifies the number of arenas that can be created before the test on the limit to the number of arenas is conducted. The default value of this tunable is 0 , meaning that the limit on the number of arenas is determined by the number of CPU cores online.

For bit systems the limit is twice the number of cores online and on bit systems, it is eight times the number of cores online. This function is a GNU extension, declared in mcheck. Calling mcheck tells malloc to perform occasional consistency checks.

Thread starter IgorGlock Start date Feb 27, IgorGlock Member Messages: I have new small problem with new gameserver DutchDaemon Administrator Staff member.

One doesn't "download libs" in FreeBSD. Indeed, it's in the compat5 port, so just install it; libc. And depending on twat your game-server needs, you may have to install other compat ports. Once you know the names of the files you need try grep 1 ping the names like Code:. IgorGlock said:. Click to expand Again: one doesn't just "download libs" in FreeBSD.

Libs are part of the base system, or installed by ports that need them. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. Asked 4 years, 3 months ago. Active 4 years, 3 months ago. Viewed times. Cloud Cloud 1. Add a comment. Active Oldest Votes.



0コメント

  • 1000 / 1000