X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=yportenv.h;h=94e72fa5481c25764067d8eac450151a3d9e3032;hb=daffb0c61b90abbfc5fd8c335c5b79b0feeff2ab;hp=fc84fc5a2ef3233f1d6eff58a663ebf93cdcd815;hpb=cefeada5db633fd3c37cde66e2e62c73052c18bd;p=yaffs%2F.git diff --git a/yportenv.h b/yportenv.h index fc84fc5..94e72fa 100644 --- a/yportenv.h +++ b/yportenv.h @@ -1,56 +1,136 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * yportenv.h: Portable services used by yaffs. This is done to allow - * simple migration from kernel space into app space for testing. - * - * Copyright (C) 2002 Aleph One Ltd. - * for Toby Churchill Ltd and Brightstar Engineering - * - * Created by Charles Manning - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - */ - -#ifndef __PORTENV_H__ -#define __PORTENV_H__ - -#ifndef __KERNEL__ - -#include "stdlib.h" -#include "stdio.h" -#include "string.h" - -#define YPRINTF(x) printf x -#define YMALLOC(x) malloc(x) -#define YFREE(x) free(x) - - -#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) -#define YALERT(s) YINFO(s) - -#else - -#include "linux/kernel.h" -#include "linux/mm.h" -#include "linux/string.h" -#include "linux/slab.h" - -#define YPRINTF(x) printk x -#define YMALLOC(x) kmalloc(x,GFP_KERNEL) -#define YFREE(x) kfree(x) - -#endif - - - -#define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s)) -#define YALERT(s) YINFO(s) - -#endif - - - - +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * yportenv.h: Portable services used by yaffs. This is done to allow + * simple migration from kernel space into app space for testing. + * + * Copyright (C) 2002 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Charles Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#ifndef __PORTENV_H__ +#define __PORTENV_H__ + + +#if defined WIN32 + +// Win32 +#include "stdlib.h" +#include "stdio.h" +#include "string.h" + +#define YMALLOC(x) malloc(x) +#define YFREE(x) free(x) + + +#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) +#define YALERT(s) YINFO(s) + +#include + +#define YAFFS_LOSTNFOUND_NAME "LOST-N-FOUND" +#define YAFFS_LOSTNFOUND_PREFIX "OBJ" + +#define YPRINTF(x) + +// Always pass the sum compare to overcome the case insensitivity issue +#define yaffs_SumCompare(x,y) 1 +#define yaffs_strcmp(a,b) _stricmp(a,b) + + +#define u_char unsigned char +#define loff_t int +#define S_IFDIR 04000 + +#define S_ISFIFO(x) 0 +#define S_ISCHR(x) 0 +#define S_ISBLK(x) 0 +#define S_ISSOCK(x) 0 + +extern unsigned yfsd_U32FileTimeNow(void); + +#define CURRENT_TIME yfsd_U32FileTimeNow() +#define YAFFS_ROOT_MODE FILE_ATTRIBUTE_ARCHIVE + + +#define TENDSTR "\r\n" +#define TSTR(x) TEXT(x) +#define T(x) RETAILMSG(1, x) + + +#elif defined __KERNEL__ + + + +// Linux kernel +#include "linux/kernel.h" +#include "linux/mm.h" +#include "linux/string.h" +#include "linux/slab.h" +#define YAFFS_LOSTNFOUND_NAME "lost+found" +#define YAFFS_LOSTNFOUND_PREFIX "obj" + +#define YPRINTF(x) printk x +#define YMALLOC(x) kmalloc(x,GFP_KERNEL) +#define YFREE(x) kfree(x) + +#define YAFFS_ROOT_MODE 0666 + + +#define yaffs_SumCompare(x,y) ((x) == (y)) +#define yaffs_strcmp(a,b) strcmp(a,b) + +#define TENDSTR "\n" +#define TSTR(x) KERN_DEBUG x +#define T(x) printk x + + +#else + +// Linux application +#include "stdlib.h" +#include "stdio.h" +#include "string.h" + +#define YMALLOC(x) malloc(x) +#define YFREE(x) free(x) + + +#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) +#define YALERT(s) YINFO(s) + + +#define TENDSTR "\n" +#define TSTR(x) x +#define T(x) printf x + + +#define YAFFS_LOSTNFOUND_NAME "lost+found" +#define YAFFS_LOSTNFOUND_PREFIX "obj" +#define YPRINTF(x) printf x + +#define CURRENT_TIME 0 +#define YAFFS_ROOT_MODE 0666 + +#define yaffs_SumCompare(x,y) ((x) == (y)) +#define yaffs_strcmp(a,b) strcmp(a,b) + +#endif + + + +#undef YINFO + + +#define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s)) +#define YALERT(s) YINFO(s) + + + +#endif