X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=oslib%2Flibmtd_common.h;h=4ed9f0ba8fde036807f163297a333a191aeb623f;hb=029b42ace698eae477c5e261d2f82b191507526b;hp=9768066b6a4449a562802ba972c6507eaf044494;hpb=3bf80dad77448afcb18148e72dc6cfe04bcf7e57;p=fio.git diff --git a/oslib/libmtd_common.h b/oslib/libmtd_common.h index 9768066b..4ed9f0ba 100644 --- a/oslib/libmtd_common.h +++ b/oslib/libmtd_common.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Imported from mtd-utils by dehrenberg */ @@ -49,18 +49,18 @@ extern "C" { #define min(a, b) MIN(a, b) /* glue for linux kernel source */ #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) -#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) +#define ALIGN(x,a) __ALIGN_MASK(x,(__typeof__(x))(a)-1) #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) #define min_t(t,x,y) ({ \ - typeof((x)) _x = (x); \ - typeof((y)) _y = (y); \ + __typeof__((x)) _x = (x); \ + __typeof__((y)) _y = (y); \ (_x < _y) ? _x : _y; \ }) #define max_t(t,x,y) ({ \ - typeof((x)) _x = (x); \ - typeof((y)) _y = (y); \ + __typeof__((x)) _x = (x); \ + __typeof__((y)) _y = (y); \ (_x > _y) ? _x : _y; \ }) @@ -119,57 +119,6 @@ extern "C" { fprintf(stderr, "%s: warning!: " fmt "\n", PROGRAM_NAME, ##__VA_ARGS__); \ } while(0) -#if defined(__UCLIBC__) -/* uClibc versions before 0.9.34 don't have rpmatch() */ -#if __UCLIBC_MAJOR__ == 0 && \ - (__UCLIBC_MINOR__ < 9 || \ - (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 34)) -#undef rpmatch -#define rpmatch __rpmatch -static inline int __rpmatch(const char *resp) -{ - return (resp[0] == 'y' || resp[0] == 'Y') ? 1 : - (resp[0] == 'n' || resp[0] == 'N') ? 0 : -1; -} -#endif -#endif - -/** - * prompt the user for confirmation - */ -static inline bool prompt(const char *msg, bool def) -{ - char *line = NULL; - size_t len; - bool ret = def; - - do { - normsg_cont("%s (%c/%c) ", msg, def ? 'Y' : 'y', def ? 'n' : 'N'); - fflush(stdout); - - while (getline(&line, &len, stdin) == -1) { - printf("failed to read prompt; assuming '%s'\n", - def ? "yes" : "no"); - break; - } - - if (strcmp("\n", line) != 0) { - switch (rpmatch(line)) { - case 0: ret = false; break; - case 1: ret = true; break; - case -1: - puts("unknown response; please try again"); - continue; - } - } - break; - } while (1); - - free(line); - - return ret; -} - static inline int is_power_of_2(unsigned long long n) { return (n != 0 && ((n & (n - 1)) == 0));