Browse Source

Rewrite printnum_{slong,ulong,ptr,kptr} using dispatch_{word,klong}size

* defs.h (printnum_long_int, printnum_addr_long_int, printnum_addr_klong_int):
Remove declaration.
(printnum_slong, printnum_ulong): Implement unconditionally using
dispatch_wordsize and opt_wordsize for the last argument.
(printnum_ptr): Implement unconditionally using dispatch_wordsize.
(printnum_kptr): Implement unconditionally using dispatch_klongsize.
* util.c (printnum_long_int, printnum_addr_long_int, printnum_addr_klong_int):
Remove.
Eugene Syromyatnikov 3 months ago
parent
commit
67267b400f
2 changed files with 8 additions and 110 deletions
  1. 8
    75
      defs.h
  2. 0
    35
      util.c

+ 8
- 75
defs.h View File

@@ -1272,101 +1272,34 @@ DECL_PRINTNUM_ADDR(int64);
1272 1272
 extern bool
1273 1273
 printnum_fd(struct tcb *, kernel_ulong_t addr);
1274 1274
 
1275
-# ifndef current_wordsize
1276
-extern bool
1277
-printnum_long_int(struct tcb *, kernel_ulong_t addr,
1278
-		  const char *fmt_long, const char *fmt_int)
1279
-	ATTRIBUTE_FORMAT((printf, 3, 0))
1280
-	ATTRIBUTE_FORMAT((printf, 4, 0));
1281
-
1282
-extern bool printnum_addr_long_int(struct tcb *, kernel_ulong_t addr);
1283
-
1284 1275
 static inline bool
1285 1276
 printnum_slong(struct tcb *tcp, kernel_ulong_t addr)
1286 1277
 {
1287
-	return printnum_long_int(tcp, addr, "%" PRId64, "%d");
1278
+	return dispatch_wordsize(printnum_int64, printnum_int,
1279
+				 tcp, addr, opt_wordsize("%" PRId64, "%d"));
1288 1280
 }
1289 1281
 
1290 1282
 static inline bool
1291 1283
 printnum_ulong(struct tcb *tcp, kernel_ulong_t addr)
1292 1284
 {
1293
-	return printnum_long_int(tcp, addr, "%" PRIu64, "%u");
1285
+	return dispatch_wordsize(printnum_int64, printnum_int,
1286
+				 tcp, addr, opt_wordsize("%" PRIu64, "%u"));
1294 1287
 }
1295 1288
 
1296 1289
 static inline bool
1297 1290
 printnum_ptr(struct tcb *tcp, kernel_ulong_t addr)
1298 1291
 {
1299
-	return printnum_addr_long_int(tcp, addr);
1292
+	return dispatch_wordsize(printnum_addr_int64, printnum_addr_int,
1293
+				 tcp, addr);
1300 1294
 }
1301 1295
 
1302
-# elif current_wordsize > 4
1303
-
1304
-static inline bool
1305
-printnum_slong(struct tcb *tcp, kernel_ulong_t addr)
1306
-{
1307
-	return printnum_int64(tcp, addr, "%" PRId64);
1308
-}
1309
-
1310
-static inline bool
1311
-printnum_ulong(struct tcb *tcp, kernel_ulong_t addr)
1312
-{
1313
-	return printnum_int64(tcp, addr, "%" PRIu64);
1314
-}
1315
-
1316
-static inline bool
1317
-printnum_ptr(struct tcb *tcp, kernel_ulong_t addr)
1318
-{
1319
-	return printnum_addr_int64(tcp, addr);
1320
-}
1321
-
1322
-# else /* current_wordsize == 4 */
1323
-
1324
-static inline bool
1325
-printnum_slong(struct tcb *tcp, kernel_ulong_t addr)
1326
-{
1327
-	return printnum_int(tcp, addr, "%d");
1328
-}
1329
-
1330
-static inline bool
1331
-printnum_ulong(struct tcb *tcp, kernel_ulong_t addr)
1332
-{
1333
-	return printnum_int(tcp, addr, "%u");
1334
-}
1335
-
1336
-static inline bool
1337
-printnum_ptr(struct tcb *tcp, kernel_ulong_t addr)
1338
-{
1339
-	return printnum_addr_int(tcp, addr);
1340
-}
1341
-
1342
-# endif
1343
-
1344
-# ifndef current_klongsize
1345
-extern bool printnum_addr_klong_int(struct tcb *, kernel_ulong_t addr);
1346
-
1347
-static inline bool
1348
-printnum_kptr(struct tcb *tcp, kernel_ulong_t addr)
1349
-{
1350
-	return printnum_addr_klong_int(tcp, addr);
1351
-}
1352
-
1353
-# elif current_klongsize > 4
1354
-
1355
-static inline bool
1356
-printnum_kptr(struct tcb *tcp, kernel_ulong_t addr)
1357
-{
1358
-	return printnum_addr_int64(tcp, addr);
1359
-}
1360
-
1361
-# else /* current_klongsize == 4 */
1362
-
1363 1296
 static inline bool
1364 1297
 printnum_kptr(struct tcb *tcp, kernel_ulong_t addr)
1365 1298
 {
1366
-	return printnum_addr_int(tcp, addr);
1299
+	return dispatch_klongsize(printnum_addr_int64, printnum_addr_int,
1300
+				  tcp, addr);
1367 1301
 }
1368 1302
 
1369
-# endif
1370 1303
 
1371 1304
 # define DECL_PRINTPAIR(name)						\
1372 1305
 extern bool								\

+ 0
- 35
util.c View File

@@ -360,41 +360,6 @@ printnum_fd(struct tcb *const tcp, const kernel_ulong_t addr)
360 360
 	return true;
361 361
 }
362 362
 
363
-#ifndef current_wordsize
364
-bool
365
-printnum_long_int(struct tcb *const tcp, const kernel_ulong_t addr,
366
-		  const char *const fmt_long, const char *const fmt_int)
367
-{
368
-	if (current_wordsize > sizeof(int)) {
369
-		return printnum_int64(tcp, addr, fmt_long);
370
-	} else {
371
-		return printnum_int(tcp, addr, fmt_int);
372
-	}
373
-}
374
-
375
-bool
376
-printnum_addr_long_int(struct tcb *tcp, const kernel_ulong_t addr)
377
-{
378
-	if (current_wordsize > sizeof(int)) {
379
-		return printnum_addr_int64(tcp, addr);
380
-	} else {
381
-		return printnum_addr_int(tcp, addr);
382
-	}
383
-}
384
-#endif /* !current_wordsize */
385
-
386
-#ifndef current_klongsize
387
-bool
388
-printnum_addr_klong_int(struct tcb *tcp, const kernel_ulong_t addr)
389
-{
390
-	if (current_klongsize > sizeof(int)) {
391
-		return printnum_addr_int64(tcp, addr);
392
-	} else {
393
-		return printnum_addr_int(tcp, addr);
394
-	}
395
-}
396
-#endif /* !current_klongsize */
397
-
398 363
 /**
399 364
  * Prints time to a (static internal) buffer and returns pointer to it.
400 365
  * Returns NULL if the provided time specification is not correct.

Loading…
Cancel
Save