Skip to content
Browse files

Lots of changes around build flags and "cleaness"

  • Loading branch information...
1 parent 06426f5 commit b6534afcc87d3c1048a9ef62efdb06654d8c0017 Pierre Carrier committed
Showing with 127 additions and 18 deletions.
  1. +5 −0 .gitignore
  2. +1 −1 COPYING
  3. +5 −0 INSTALL
  4. +7 −3 auth/grouplist.c
  5. +3 −2 diagnostics/gdb4undeads.c
  6. +0 −1 diagnostics/memcpy2memmove.c
  7. +8 −3 fs/wtfitf.c
  8. +1 −1 fun/async/test-poll.c
  9. +4 −0 mem/hugepagesdoublecheck.c
  10. +4 −0 mem/hugepagesmaxalloc.c
  11. +1 −1 mini/echo.c
  12. +2 −0 mini/hostid.c
  13. +2 −0 mini/sync.c
  14. +2 −0 prepare.sh
  15. +3 −3 sys/errnos.h.gen
  16. +5 −3 sys/sethostid.c
  17. +74 −0 wscript
View
5 .gitignore
@@ -1,2 +1,7 @@
+waf
+.waf-1*
*~
+*.swp
+.lock-w*
sys/errnos.h
+build/
View
2 COPYING
@@ -1,4 +1,4 @@
Copyright (c) 2010, Red Hat Inc.
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided that
-the above copyright notice and this permission notice appear in all copies.
+the above copyright notice and this permission notice appear in all copies.
View
5 INSTALL
@@ -0,0 +1,5 @@
+- Get waf:
+
+ $ ./prepare.sh
+
+-
View
10 auth/grouplist.c
@@ -12,9 +12,13 @@
* If no file is specified, goes through all nss backends
*/
+#define _SVID_SOURCE
+
+#include <stdlib.h>
+#include <stdio.h>
#include <sys/types.h>
#include <grp.h>
-#include <stdio.h>
+#include <err.h>
void showgrp(const struct group *grp)
{
@@ -22,7 +26,7 @@ void showgrp(const struct group *grp)
if (!printf("%s:%s:%i:", grp->gr_name, grp->gr_passwd, grp->gr_gid))
exit(2);
for (gr_mem = grp->gr_mem; **gr_mem != '\0'; gr_mem++)
- if(!printf("%s,", gr_mem))
+ if(!printf("%s,", *gr_mem))
exit(3);
if(!puts(""))
exit(4);
@@ -36,7 +40,7 @@ int main(int argc, char **argv)
if (argc > 1) {
if (!(grpfile = fopen(argv[1], "r")))
err(1, "could not open group file '%s'", argv[1]);
- while (grp = fgetgrent(grpfile))
+ while ((grp = fgetgrent(grpfile)))
showgrp(grp);
} else {
setgrent();
View
5 diagnostics/gdb4undeads.c
@@ -31,13 +31,14 @@
#include <sys/param.h>
#include <dlfcn.h>
+typedef ssize_t readlink_t (const char *, char *, size_t);
+
ssize_t readlink(const char *path, char *buf, size_t bufsiz)
{
char ibuf[PATH_MAX];
char *result = ibuf;
ssize_t rc;
- ssize_t(*orig_readlink) (const char *path, char *buf, size_t bufsiz) =
- dlsym(RTLD_NEXT, "readlink");
+ readlink_t * orig_readlink = (readlink_t *) dlsym(RTLD_NEXT, "readlink");
rc = orig_readlink(path, ibuf, bufsiz);
if (rc < 0)
goto done;
View
1 diagnostics/memcpy2memmove.c
@@ -20,7 +20,6 @@
* Warning: This will impact performance!
**/
-#define _GNU_SOURCE 1
#include <string.h>
#include <stdio.h>
View
11 fs/wtfitf.c
@@ -12,6 +12,8 @@
* Maintainer: Pierre Carrier <prc@redhat.com>
**/
+#define __STDC_FORMAT_MACROS
+
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
@@ -21,10 +23,11 @@
#include <linux/fiemap.h>
#include <errno.h>
#include <string.h>
+#include <inttypes.h>
struct flags_descr {
const char *name;
- __u64 mask;
+ uint64_t mask;
};
static struct flags_descr known_flags[] = {
@@ -57,8 +60,10 @@ void print_extent(struct fiemap_extent *extent)
__u32 flags = extent->fe_flags;
struct flags_descr *cur_descr;
int num_flags = 0;
- printf("0x%016llx\t0x%016llx\t0x%016llx\t", extent->fe_logical,
- extent->fe_physical, extent->fe_length);
+ printf("0x%016llx\t0x%016llx\t0x%016llx\t",
+ (uint64_t)(extent->fe_logical),
+ (uint64_t)(extent->fe_physical),
+ (uint64_t)(extent->fe_length));
if (!flags) {
printf("none\n");
return;
View
2 fun/async/test-poll.c
@@ -4,7 +4,7 @@
#include <fcntl.h>
#include <poll.h>
-int main(int argc, char **argv)
+int main()
{
int ret, fd_flags;
char buff[1024];
View
4 mem/hugepagesdoublecheck.c
@@ -22,6 +22,10 @@
/* 256MB */
#define LENGTH (256UL*1024*1024)
+#ifndef SHM_HUGETLB
+# define SHM_HUGETLB 04000
+#endif
+
/* Only ia64 requires this */
#ifdef __ia64__
#define ADDR (void *)(0x8000000000000000UL)
View
4 mem/hugepagesmaxalloc.c
@@ -24,6 +24,10 @@
#define PRECISION (unsigned long)(1<<20)
#define MB (unsigned long)(1<<20)
+#ifndef SHM_HUGETLB
+# define SHM_HUGETLB 04000
+#endif
+
/* Only ia64 requires this */
#ifdef __ia64__
#define ADDR (void *)(0x8000000000000000UL)
View
2 mini/echo.c
@@ -25,7 +25,7 @@ static int print(char *str, int parse_backslashes)
ESCAPED_REGISTER('\\', '\\');
ESCAPED_REGISTER('a', '\a');
ESCAPED_REGISTER('b', '\b');
- ESCAPED_REGISTER('e', '\e');
+ ESCAPED_REGISTER('e', (char)27);
ESCAPED_REGISTER('f', '\f');
ESCAPED_REGISTER('n', '\n');
ESCAPED_REGISTER('r', '\r');
View
2 mini/hostid.c
@@ -2,6 +2,8 @@
* A simple 'hostid' implementation for fun
**/
+#define _BSD_SOURCE
+
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
View
2 mini/sync.c
@@ -2,6 +2,8 @@
* A simple 'sync' implementation for fun
**/
+#define _BSD_SOURCE
+
#include <stdlib.h>
#include <unistd.h>
View
2 prepare.sh
@@ -0,0 +1,2 @@
+curl http://waf.googlecode.com/files/waf-1.6.4 > waf
+chmod +x waf
View
6 sys/errnos.h.gen
@@ -1,5 +1,5 @@
-#!/usr/bin/bash
-grep -v '^#' sys/errnos.list |
+#!/bin/bash
+grep -v '^#' $1 |
while read errno; do
echo -e "#ifdef $errno\n ERRNO_EXISTS($errno, \"$errno\");\n#endif"
-done > sys/errnos.h
+done > $2
View
8 sys/sethostid.c
@@ -9,10 +9,13 @@
* Maintainer: Pierre Carrier <prc@redhat.com>
**/
+#define _BSD_SOURCE
+
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
+#include <err.h>
#include <string.h> /* required by strerror */
int main(int argc, char **argv)
@@ -23,7 +26,7 @@ int main(int argc, char **argv)
if (argc != 2)
goto err;
- length = strnlen(argv[1], 9);
+ length = strlen(argv[1]);
if (length != 8 || sscanf(argv[1], "%x", &new_hostid) != 1)
goto err;
@@ -39,8 +42,7 @@ int main(int argc, char **argv)
return EXIT_SUCCESS;
err:
- fprintf(stderr, "Usage: %s id\n"
+ errx(EXIT_FAILURE, "Usage: %s id\n"
"id is an 8-char hexadecimal representation, "
"as in the output of 'hostid'.\n", argv[0]);
- return EXIT_FAILURE;
}
View
74 wscript
@@ -0,0 +1,74 @@
+APPNAME='stuff'
+VERSION='0.1'
+
+portable_bins = [
+ 'auth/grouplist',
+ 'fun/b2c',
+ 'fun/mkpasswd',
+ 'fun/nato',
+ 'fun/superglob',
+ 'mem/eatmemory',
+ 'mem/mmapdoublecheck',
+ 'mem/mmapnwait',
+ 'sys/sethostid'
+]
+
+preload_libs = [
+ 'diagnostics/gdb4undeads',
+ 'diagnostics/memcpy2memmove',
+ 'diagnostics/mtrace'
+]
+
+linux_bins = [
+ 'fs/wtfitf',
+ 'mem/hugepagesdoublecheck',
+ 'mem/hugepagesmaxalloc'
+]
+
+test_bins = [
+ 'fun/async/test-poll',
+ 'fun/async/test-select',
+ 'sys/i_segv2',
+ 'sys/i_segv3',
+ 'sys/i_segv'
+
+]
+
+mini_bins = [
+ 'mini/echo',
+ 'mini/false',
+ 'mini/hostid',
+ 'mini/logname',
+ 'mini/sync',
+ 'mini/true',
+ 'mini/yes',
+ 'mini/yes2'
+]
+
+glib_bins = [
+ 'sys/errnos'
+]
+
+from waflib.Task import Task
+
+def options(opt):
+ opt.load('compiler_c')
+
+def configure(cnf):
+ cnf.load('compiler_c')
+ cnf.check(header_name = 'linux/fiemap.h', mandatory=False) #features='c cprogram', mandatory=False)
+ cnf.check_cc(cflags=['-Wall','-Wextra', '-pedantic', '-std=c99'], defines=['_XOPEN_SOURCE'], uselib_store='base')
+ cnf.check_cc(lib=['m'], uselib_store='M')
+ cnf.check_cc(cflags=['-Werror'], uselib_store='strict')
+ cnf.check_cfg(package='glib-2.0', args=['--cflags', '--libs'], use='portable', uselib_store='glib2')
+ cnf.write_config_header('config.h')
+
+def build(bld):
+ bld(rule=bld.path.abspath()+'/sys/errnos.h.gen ${SRC} ${TGT} ${ROOT}', source='sys/errnos.list', target='errnos.h')
+ for bin in portable_bins+mini_bins+test_bins:
+ bld.program(source=bin+'.c', target=bin, use=['base', 'strict', 'M'])
+ for lib in preload_libs:
+ # I stopped trying to be strict here...
+ bld.shlib(source=lib+'.c', target=lib, use=['base', 'M'])
+ for bin in linux_bins:
+ bld.program(source=bin+'.c', target=bin, use=['base', 'strict', 'M'])

0 comments on commit b6534af

Please sign in to comment.
Something went wrong with that request. Please try again.