summaryrefslogtreecommitdiffstats
path: root/include/c.h
Commit message (Collapse)AuthorAgeFilesLines
* include/c: add macro UL_CLOEXECSTRKarel Zak2013-04-031-0/+8
| | | | | | ... to make "e" for fopen() portable to systems without O_CLOEXEC. Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: arch is gone, use delpart as usage() function exampleSami Kerola2013-03-261-1/+1
| | | | | | The arch.c was removed in commit 27abd809. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sulogin: make usleep() workaround workWerner Fink2012-12-181-3/+7
| | | | | | Simply fix a compile problem found during debugging console.c Signed-off-by: Werner Fink <werner@suse.de>
* include/c: move usleep() fallback to c.hKarel Zak2012-10-221-0/+15
| | | | | | To make it available everywhere in code. Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: remove MAXHOSTNAMELEN macroKarel Zak2012-10-191-11/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: add get_hostname_max() inline functionSami Kerola2012-10-191-0/+18
| | | | | | | | | | | | Using sysconf(_SC_HOST_NAME_MAX) does not work everywhere. At such even header values for hostname length should be preferred, and if nothing else works guess the maxium being 64 bytes. Based-on-code-by: Karel Zak <kzak@redhat.com> CC: Mike Frysinger <vapier@gentoo.org> References: http://www.spinics.net/lists/util-linux-ng/msg07050.html Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: add fileback for SEEK_DATAKarel Zak2012-07-241-0/+11
| | | | | Reported-by: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: move fallback for MAXHOSTNAMELEN to c.hKarel Zak2012-05-291-0/+11
| | | | | Reported-by: Thomas Schwinge <thomas@codesourcery.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* include: [c.h] protect container_ofmaximilian attems2012-05-231-0/+2
| | | | | | | | | | fixes lots of warning noise: ../../../include/c.h:112:0: warning: "container_of" redefined [enabled by default] /usr/lib/klibc/include/stddef.h:52:0: note: this is the location of the previous definition Signed-off-by: maximilian attems <max@stro.at>
* losetup: make xgetpass more robustKarel Zak2012-01-171-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lists: add list sorting routineDavidlohr Bueso2011-12-161-0/+8
| | | | | | | | | | | | | | | | | We need a list sorting function, just to mention one example user that could benefit is the lib/tt code to sort columns. This patch adds list_sort() which uses the Merge Sort algorithm, behaving nicely in O(nlog(n)), heavily based on the kernel's implementation[1]. The private data (void *priv) passed to the comparison function as been removed to adopt a qsort(3)-like syntax, and IMHO we don't really need it anyways. [1]: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=lib/list_sort.c;h=d7325c6b103f0be078ff3672c35c468ed35738f1;hb=HEAD [kzak@redhat.com: - use size_t in list_sort()] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: check scanf %ms modifierKarel Zak2011-10-101-0/+9
| | | | | | | | | | | | Without the check libmount builds on systems that has older than 2.7 glibc are silently unsuccessful. The missing %ms modifier will, at least, result on such system missing output of findmnt and lsblk commands. If either %ms or %as modifiers are present the libmount build is disabled. Based on patch from: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: rename BUILD_BUG_ON_ZERO definitionSami Kerola2011-10-101-2/+2
| | | | | | | | | | | | Definition name is changed to UL_BUILD_BUG_ON_ZERO to avoid collision with a system header. ../include/c.h:72:1: warning: "BUILD_BUG_ON_ZERO" redefined In file included from /usr/include/sys/sysinfo.h:25, from dmesg.c:16: /usr/include/linux/kernel.h:34:1: warning: this is the location of the previous definition Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: use %m in format string instead of %s and strerror(errno)Petr Uzel2011-09-271-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* Merge branch 'sys-utils' of https://github.com/kerolasa/lelux-utiliteetitKarel Zak2011-09-271-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'sys-utils' of https://github.com/kerolasa/lelux-utiliteetit: (29 commits) docs: add non-return function and if shorthand tips build-sys: fixes to USAGE_* macros ipcrm: check IPC syscalls ipcrm: add --verbose option ipcmk: allow high speed ipc creation ipcrm: add --all option docs: add long options to ipcs.1 man page docs: add long options to ipcrm.1 man page docs: add long options to ipcmk.1 man page docs: add --version to setarch.8 docs: mention long options in ctrlaltdel.8 ctrlaltdel: add version & help options docs: mention long options in pivot_root.8 pivot_root: add version & help option ipcs: comment & white space clean up ipcs: include-what-you-use header check ipcs: add long options ipcrm: include-what-you-use header check ipcrm: refactor new and old main to share code ipcrm: exit if unknown error occurs ...
| * build-sys: fixes to USAGE_* macrosSami Kerola2011-09-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | The USAGE_BEGIN_TAIL is removed as unnecessary. In between command specific options and --help & --version USAGE_SEPARATOR is inserted. For now the separator is empty line. The USAGE_MAN_TAIL is changed to take an argument. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | include,c.h: include fcntl.h before check for O_CLOEXEC [smatch scan]Karel Zak2011-09-121-0/+1
|/ | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* arch: start using arch as a usage() exampleSami Kerola2011-08-281-0/+13
| | | | | | | The arch command is hijacked to be example of howto write usage as defined in Documentation/howto-usage-function.txt Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: [c.h] Include stdlib.h unconditionalymaximilian attems2011-08-021-1/+1
| | | | | | | No point in hiding it down in an ifdef maze, as it may get used by exit(3). Signed-off-by: maximilian attems <max@stro.at>
* include: [c.h] move up declaration of program_invocation_short_name before usagemaximilian attems2011-08-021-35/+35
| | | | | | | | | | | fixes: ../include/c.h: In function ‘errmsg’: ../include/c.h:111:26: error: ‘program_invocation_short_name’ undeclared (first use in this function) ../include/c.h:111:26: note: each undeclared identifier is reported only once for each function it appears in Signed-off-by: maximilian attems <max@stro.at>
* include: [c.h] add definition wrappers for old libc versionsDavidlohr Bueso2011-03-291-1/+11
| | | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* include: [c.h]: remove strings.h include dublicateSami Kerola2011-03-081-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: [c.h]: typeof to __typeof__ fixSami Kerola2011-03-081-6/+6
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-0/+47
| | | | | | | | Solaris lacks err, errx, warn and warnx. This also means the err.h header doesn't exist. Removed err.h include from all files, and included err.h from c.h instead if it exists, otherwise alternatives are provided. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* include: [c.h]: add fallback for old libs without O_CLOEXECKarel Zak2011-02-111-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: [c.h]: add unused attribute to ignore_result()Karel Zak2011-02-091-1/+3
| | | | | | | | | | | | | | unfortunately, gcc 4.6 void fn (void) { int foo; foo = bar (); } evaluates that foo is never used. The __attribute__((unused)) is necessary... Signed-off-by: Karel Zak <kzak@redhat.com>
* include: [c.h]: fix __alloc_size__ testKarel Zak2011-02-081-2/+2
| | | | | Reported-by: Francesco Cosoleto <cosoleto@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* include: [c.h] add fallback for alloc_size attributesKarel Zak2011-02-071-0/+27
| | | | | Reported-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* include: [c.h] move ignore_result() to gcc-only blockKarel Zak2011-02-071-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* provide a workaround if program_invocation_short_name is missingFabian Groffen2011-01-311-0/+36
| | | | | | | | | | | | Try some replacements, such as getexecname() on Solaris and __progname on BSDs and Darwin. When not found, base program_invocation_short_name on the source filename it is used in, as not to require argv[0] to be passed along. This latter approach is not dynamic, but doesn't require code changes for all places where program_invocation_short_name is used now. Signed-off-by: Fabian Groffen <grobian@gentoo.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* include: emulate dirfd when necessaryFabian Groffen2011-01-231-0/+9
| | | | | | | | | | | | dirfd is not available on Solaris 10, it is available on latest OpenSolaris releases though. Do some autoconf trickery to determine if providing an alternative dirfd function is necessary and possible. shlibs/blkid/src/read.c: Do not define _XOPEN_SOURCE to 600, or DIR will lose it's dd_fd member again. Rearrange defines and includes to make sense per comments, and not conflict on Solaris. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* build-sys: check for loff_t, it may not existFabian Groffen2011-01-201-0/+4
| | | | | | | On some systems, loff_t does not exist. Define it as int64_t in that case. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* lib: [c] add ignore_result()Karel Zak2011-01-041-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: fix MBR detection on iPod and cleanup vfat codeKarel Zak2010-10-151-0/+6
| | | | | | | | | | | - move all FAT code to superblocks/vfat.c only - add a generic function to verify FAT superblock and use it in FAT prober as well as in MBR parser - add a more robust FAT cluster_count check (it seems that iPod contains an "almost valid" FAT superblock before MBR) Reported-by: Davidlohr Bueso <dave.bueso@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add #ifndef around min() max() macrosKarel Zak2010-03-161-3/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: add min/max macrosKarel Zak2010-02-121-0/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: add c.h with fundamental C definitionsKarel Zak2009-10-161-0/+49
Add: * ARRAY_SIZE with array type check * PATH_MAX, TRUE and FALSE macros * dummy __attribute__ for non-gcc compilers Signed-off-by: Karel Zak <kzak@redhat.com>