CONTENT
  • CHANGES
Szukaj
counter

#top Memory


code / ansic / memory

#top Makefile


Dla ułatwienia korzystania z przykładów został utworzony jeden zbiorczy plik Makefile kompilujący przykłady użycia poniżej wymienionych funkcji związanych z operacjami na systemie plików (funkcja dotyczące operacji na plikach).

Poniższe pliki Makefile zakładają obecność wszystkich plików przykładów, w przypadku chęci kompilacji za pomocą Makefile tylko wybranego przykładu należy zakomentować w pliku Makefile ostatnią pozycję zawierającą listę wszystkich targetów do wykonania make: $(ACCESS) ..., a następnie odkomentować powyżej komendę make zawierającą nazwę targetu dla bieżącego przykładu, np: w przypadku chęci kompilacji tylko przykładu access należy zakomentować ostatnią pozycję rozpoczynającą się od make: $(ACCESS) ... (wstawić na początku przed make znak #), a następnie odkomentować pozycję: #make: $(ACCESS) (usunąć znak #).

#top Makefile (linux)


SELECT ALL




#top Makefile.obsd


SELECT ALL




#top Makefile.fbsd


SELECT ALL




#top Makefile.sol


SELECT ALL




#top Makefile.beos


SELECT ALL




#top Makefile.win


SELECT ALL






#top Predefined Constants






#top Datatypes / MACROS


#top __mode_t


Definicja typu __mode_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __mode_t jest następująca:
__STD_TYPE __MODE_T_TYPE __mode_t;  /* Type of file attribute bitmasks.  */



#top __off_t


Definicja typu __off_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __off_t jest następująca:
__STD_TYPE __OFF_T_TYPE __off_t;    /* Type of file sizes and offsets.  */



#top mode_t


Definicja typu mode_t znajduje się w pliku nagłówkowym sys/mman.h.
Definicja typu mode_t jest następująca:
#ifndef __mode_t_defined
typedef __mode_t mode_t;
# define __mode_t_defined
#endif



#top size_t


Definicja typu size_t znajduje się w pliku nagłówkowym /usr/lib/gcc/i386-redhat-linux/4.1.1/include/stddef.h.
Definicja typu size_t jest następująca:
/* Unsigned type of `sizeof' something.  */

/* Define this type if we are doing the whole job,
   or if we want this type in particular.  */
#if defined (_STDDEF_H) || defined (__need_size_t)
#ifndef __size_t__	/* BeOS */
#ifndef __SIZE_T__	/* Cray Unicos/Mk */
#ifndef _SIZE_T	/* in case <sys/types.h> has defined it. */
#ifndef _SYS_SIZE_T_H
#ifndef _T_SIZE_
#ifndef _T_SIZE
#ifndef __SIZE_T
#ifndef _SIZE_T_
#ifndef _BSD_SIZE_T_
#ifndef _SIZE_T_DEFINED_
#ifndef _SIZE_T_DEFINED
#ifndef _BSD_SIZE_T_DEFINED_	/* Darwin */
#ifndef _SIZE_T_DECLARED	/* FreeBSD 5 */
#ifndef ___int_size_t_h
#ifndef _GCC_SIZE_T
#ifndef _SIZET_
#ifndef __size_t
#define __size_t__	/* BeOS */
#define __SIZE_T__	/* Cray Unicos/Mk */
#define _SIZE_T
#define _SYS_SIZE_T_H
#define _T_SIZE_
#define _T_SIZE
#define __SIZE_T
#define _SIZE_T_
#define _BSD_SIZE_T_
#define _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED
#define _BSD_SIZE_T_DEFINED_	/* Darwin */
#define _SIZE_T_DECLARED	/* FreeBSD 5 */
#define ___int_size_t_h
#define _GCC_SIZE_T
#define _SIZET_
#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
/* __size_t is a typedef on FreeBSD 5!, must not trash it. */
#else
#define __size_t
#endif
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
#endif
#if !(defined (__GNUG__) && defined (size_t))
typedef __SIZE_TYPE__ size_t;
#ifdef __BEOS__
typedef long ssize_t;
#endif /* __BEOS__ */
#endif /* !(defined (__GNUG__) && defined (size_t)) */
#endif /* __size_t */
#endif /* _SIZET_ */
#endif /* _GCC_SIZE_T */
#endif /* ___int_size_t_h */
#endif /* _SIZE_T_DECLARED */
#endif /* _BSD_SIZE_T_DEFINED_ */
#endif /* _SIZE_T_DEFINED */
#endif /* _SIZE_T_DEFINED_ */
#endif /* _BSD_SIZE_T_ */
#endif /* _SIZE_T_ */
#endif /* __SIZE_T */
#endif /* _T_SIZE */
#endif /* _T_SIZE_ */
#endif /* _SYS_SIZE_T_H */
#endif /* _SIZE_T */
#endif /* __SIZE_T__ */
#endif /* __size_t__ */
#undef	__need_size_t
#endif /* _STDDEF_H or __need_size_t.  */





#top Filesystem Functions


#top calloc


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji calloc() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji calloc() jest następująca:
#ifndef __malloc_and_calloc_defined
# define __malloc_and_calloc_defined
__BEGIN_NAMESPACE_STD
[...]
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
extern void *calloc (size_t __nmemb, size_t __size)
     __THROW __attribute_malloc__ __wur;
     __END_NAMESPACE_STD
#endif

Powiązane:
calloc(), free(), malloc(), realloc(),

Opis:
Funkcja calloc()

Argumenty:
. -
. -

Zwracana wartość:
. -



#top free


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji free() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji free() jest następująca:
#ifndef __need_malloc_and_calloc
__BEGIN_NAMESPACE_STD
[...]
/* Free a block allocated by `malloc', `realloc' or `calloc'.  *:
extern void free (void *__ptr) __THROW;
__END_NAMESPACE_STD
[...]
#endif /* don't just need malloc and calloc */

Powiązane:
calloc(), free(), malloc(), realloc(),

Opis:
Funkcja free()

Argumenty:
. -
. -

Zwracana wartość:
. -



#top malloc


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji malloc() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji malloc() jest następująca:
#ifndef __malloc_and_calloc_defined
# define __malloc_and_calloc_defined
__BEGIN_NAMESPACE_STD
/* Allocate SIZE bytes of memory.  */
extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
[...]
     __END_NAMESPACE_STD
#endif

Powiązane:
calloc(), free(), malloc(), realloc(),

Opis:
Funkcja malloc()

Argumenty:
. -
. -

Zwracana wartość:
. -

Example:
zawartość pliku malloc.c
SELECT ALL


program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:

program wyświetli informacje o sposobie uruchamiania programu:


jako argument wywołania programu można podać analogiczne jak poniżej argumenty:

rezultat będzie zależny od podanych argumentów wywołania programu:




#top madvise


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji madvise() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji madvise() jest następująca:
#ifdef __USE_BSD
/* Advise the system about particular usage patterns the program follows
   for the region starting at ADDR and extending LEN bytes.  */
extern int madvise (void *__addr, size_t __len, int __advice) __THROW;
#endif

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja madvise()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top mincore


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji mincore() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji mincore() jest następująca:
#ifdef __USE_MISC
/* mincore returns the memory residency status of the pages in the
   current process's address space specified by [start, start + len).
   The status is returned in a vector of bytes.  The least significant
   bit of each byte is 1 if the referenced page is in memory, otherwise
   it is zero.  */
extern int mincore (void *__start, size_t __len, unsigned char *__vec)
     __THROW;
#endif

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja mincore()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top mlock


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji mlock() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji mlock() jest następująca:
/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
   be memory resident.  */
extern int mlock (__const void *__addr, size_t __len) __THROW;

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja mlock()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top mlockall


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji mlockall() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji mlockall() jest następująca:
/* Cause all currently mapped pages of the process to be memory resident
   until unlocked by a call to the `munlockall', until the process exits,
   or until the process calls `execve'.  *:
extern int mlockall (int __flags) __THROW;

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja mlockall()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top mmap


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji mmap() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji mmap() jest następująca:
/* Map addresses starting near ADDR and extending for LEN bytes.  from
   OFFSET into the file FD describes according to PROT and FLAGS.  If ADDR
   is nonzero, it is the desired mapping address.  If the MAP_FIXED bit is
   set in FLAGS, the mapping will be at ADDR exactly (which must be
   page-aligned); otherwise the system chooses a convenient nearby address.
   The return value is the actual mapping address chosen or MAP_FAILED
   for errors (in which case `errno' is set).  A successful `mmap' call
   deallocates any previous mapping for the affected region.  */

#ifndef __USE_FILE_OFFSET64
extern void *mmap (void *__addr, size_t __len, int __prot,
           int __flags, int __fd, __off_t __offset) __THROW;
#else
# ifdef __REDIRECT_NTH
extern void * __REDIRECT_NTH (mmap,
                  (void *__addr, size_t __len, int __prot,
                   int __flags, int __fd, __off64_t __offset),
                  mmap64);
# else
#  define mmap mmap64
# endif
#endif

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja mmap()

Argumenty:
void *__addr -
size_t __len -
int __prot -
int __flags -
int __fd -
__off_t __offset -

Zwracana wartość:
void * -

Example:
zawartość pliku mmap.c
SELECT ALL


program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:

program wyświetli informacje o sposobie uruchamiania programu:


jako argument wywołania programu można podać analogiczne jak poniżej argumenty:

rezultat będzie zależny od podanych argumentów wywołania programu:




#top mprotect


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji mprotect() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji mprotect() jest następująca:
/* Change the memory protection of the region starting at ADDR and
   extending LEN bytes to PROT.  Returns 0 if successful, -1 for errors
   (and sets errno).  *:
extern int mprotect (void *__addr, size_t __len, int __prot) __THROW;

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja mprotect()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top mremap


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji mremap() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji mremap() jest następująca:
#ifdef __USE_GNU
/* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length
   NEW_LEN.  If MREMAP_MAYMOVE is set in FLAGS the returned address
   may differ from ADDR.  If MREMAP_FIXED is set in FLAGS the function
   takes another paramter which is a fixed address at which the block
   resides after a successful call.  */
extern void *mremap (void *__addr, size_t __old_len, size_t __new_len,
             int __flags, ...) __THROW;
#endif

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja mremap()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top msync


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji msync() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji msync() jest następująca:
/* Synchronize the region starting at ADDR and extending LEN bytes with the
   file it maps.  Filesystem operations on a file being mapped are
   unpredictable before this is done.  Flags are from the MS_* set.

   This function is a cancellation point and therefore not marked with
   __THROW.  */
extern int msync (void *__addr, size_t __len, int __flags);

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja msync()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top munlock


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji munlock() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji munlock() jest następująca:
/* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN).  */
extern int munlock (__const void *__addr, size_t __len) __THROW;

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja munlock()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top munlockall


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji munlockall() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji munlockall() jest następująca:
/* All currently mapped pages of the process' address space become
   unlocked.  */
extern int munlockall (void) __THROW;

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja munlockall()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top munmap


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji munmap() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji munmap() jest następująca:
/* Deallocate any mapping for the region starting at ADDR and extending LEN
   bytes.  Returns 0 if successful, -1 for errors (and sets errno).  *:
extern int munmap (void *__addr, size_t __len) __THROW;

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja munmap()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top posix_madvise


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji posix_madvise() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji posix_madvise() jest następująca:
#ifdef __USE_XOPEN2K
/* This is the POSIX name for this function.  */
extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW;
#endif

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja posix_madvise()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top realloc


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji realloc() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji realloc() jest następująca:
#ifndef __need_malloc_and_calloc
__BEGIN_NAMESPACE_STD
/* Re-allocate the previously allocated block
   in PTR, making the new block SIZE bytes long.  */
extern void *realloc (void *__ptr, size_t __size)
     __THROW __attribute_malloc__ __attribute_warn_unused_result__;
[...]
__END_NAMESPACE_STD
[...]
#endif /* don't just need malloc and calloc */

Powiązane:
calloc(), free(), malloc(), realloc(),

Opis:
Funkcja realloc()

Argumenty:
. -
. -

Zwracana wartość:
. -



#top remap_file_pages


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji remap_file_pages() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji remap_file_pages() jest następująca:
#ifdef __USE_GNU
/* Remap arbitrary pages of a shared backing store within an existing
   VMA.  */
extern int remap_file_pages (void *__start, size_t __size, int __prot,
                 size_t __pgoff, int __flags) __THROW;
#endif

Powiązane:
madvise(), mincore(), mlock(), mlockall(), mmap(), mprotect(), mremap(), msync(), munlock(), munlockall(), munmap(), posix_madvise(), remap_file_pages(), shm_open(), shm_unlink(),

Opis:
Funkcja remap_file_pages()

Argumenty:
void *__addr -
size_t __len -

Zwracana wartość:
int -



#top shm_open


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji shm_open() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji shm_open() jest następująca:
/* Open shared memory segment.  */
extern int shm_open (__const char *__name, int __oflag, mode_t __mode);

Powiązane:
shm_open(), shm_unlink(),

Opis:
Funkcja shm_open()

Argumenty:
const char *__name -
int __oflag -
mode_t __mode -

Zwracana wartość:
int -

Example:
zawartość pliku shm_open.c
SELECT ALL


program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:

program wyświetli informacje o sposobie uruchamiania programu:


jako argument wywołania programu można podać analogiczne jak poniżej argumenty:

rezultat będzie zależny od podanych argumentów wywołania programu:





Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji shm_unlink() znajduje się w pliku nagłówkowym sys/mman.h.
Deklaracja funkcji shm_unlink() jest następująca:
/* Remove shared memory segment.  */
extern int shm_unlink (__const char *__name);

Powiązane:
shm_open(), shm_unlink(),

Opis:
Funkcja shm_unlink()

Argumenty:
const char *__name -

Zwracana wartość:
int -





Zmodyfikowany ostatnio: 2015/10/01 19:46:11 (9 lat temu), textsize: 38,4 kB, htmlsize: 62,9 kB

Zapraszam do komentowania, zgłaszania sugestii, propozycji, własnych przykładów, ...
Dodaj komentarzKomentarze użytkowników