Skip to content

Commit b4df944

Browse files
!compiler: drop CONFIG_HAVE_LONG_LONG and require long long support
The matching nuttx commit removes CONFIG_HAVE_LONG_LONG; clean up the remaining users in nuttx-apps so that "long long" is always assumed: - examples/noteprintf, examples/nxscope: unconditionally exercise the %lld / long long branch. - fsutils/mkfatfs/configfat.c: drop the 32-bit fall-back paths in mkfatfs_nfatsect12/16/32; always use uint64_t for the FAT-size arithmetic. - logging/nxscope/nxscope_chan.c: drop the CONFIG_HAVE_LONG_LONG guard around the 64-bit sample helpers. - netutils/ftpd, netutils/ntpclient: always emit the 64-bit format strings. - testing/fs/fstest/fstest_main.c: drop the parallel 32-bit verification path; keep only the 64-bit (long long) random pattern generator. - system/zmodem/host/nuttx/compiler.h: remove the host-side CONFIG_HAVE_LONG_LONG stub macro. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
1 parent 0105a9b commit b4df944

8 files changed

Lines changed: 8 additions & 88 deletions

File tree

examples/noteprintf/noteprintf_main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ int main(int argc, FAR char *argv[])
5353
short s = 2;
5454
int i = 3;
5555
long l = 4;
56-
#ifdef CONFIG_HAVE_LONG_LONG
5756
long long ll = 5;
58-
#endif
5957
intmax_t im = 6;
6058
size_t sz = 7;
6159
ptrdiff_t ptr = 8;
@@ -78,9 +76,7 @@ int main(int argc, FAR char *argv[])
7876
sched_note_printf(NOTE_TAG_ALWAYS, "%hd", s);
7977
sched_note_printf(NOTE_TAG_ALWAYS, "%d", i);
8078
sched_note_printf(NOTE_TAG_ALWAYS, "%ld", l);
81-
#ifdef CONFIG_HAVE_LONG_LONG
8279
sched_note_printf(NOTE_TAG_ALWAYS, "%lld", ll);
83-
#endif
8480
sched_note_printf(NOTE_TAG_ALWAYS, "%jd", im);
8581
sched_note_printf(NOTE_TAG_ALWAYS, "%zd", sz);
8682
sched_note_printf(NOTE_TAG_ALWAYS, "%td", ptr);

examples/nxscope/nxscope_main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,13 @@ static FAR void *nxscope_samples_thr(FAR void *arg)
341341

342342
nxscope_put_b16(envp->nxs, 13, ftob16(-1.0f));
343343

344-
#ifdef CONFIG_HAVE_LONG_LONG
345344
/* Channel 14 */
346345

347346
nxscope_put_ub32(envp->nxs, 14, dtob32(1.0));
348347

349348
/* Channel 15 */
350349

351350
nxscope_put_b32(envp->nxs, 15, dtob32(-1.0));
352-
#endif
353351

354352
/* Channel 16 */
355353

@@ -711,7 +709,6 @@ int main(int argc, FAR char *argv[])
711709
u.s.cri = 0;
712710
nxscope_chan_init(&nxs, 13, "chan13", u.u8, 1, 0);
713711

714-
#ifdef CONFIG_HAVE_LONG_LONG
715712
u.s.dtype = NXSCOPE_TYPE_UB32;
716713
u.s._res = 0;
717714
u.s.cri = 0;
@@ -721,7 +718,6 @@ int main(int argc, FAR char *argv[])
721718
u.s._res = 0;
722719
u.s.cri = 0;
723720
nxscope_chan_init(&nxs, 15, "chan15", u.u8, 1, 0);
724-
#endif
725721

726722
/* Vector data channel */
727723

fsutils/mkfatfs/configfat.c

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,8 @@ static inline uint32_t
121121
mkfatfs_nfatsect12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var,
122122
uint32_t navailsects)
123123
{
124-
#ifdef CONFIG_HAVE_LONG_LONG
125124
uint64_t denom;
126125
uint64_t number;
127-
#else
128-
uint32_t denom;
129-
uint32_t number;
130-
#endif
131126

132127
/* For FAT12, the cluster number is held in a 12-bit number or 1.5 bytes
133128
* per cluster reference. So each FAT sector will hold sectorsize/1.5
@@ -156,25 +151,12 @@ mkfatfs_nfatsect12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var,
156151
* navailsects > 0x55555555 - 2 * clustersize
157152
*/
158153

159-
#ifndef CONFIG_HAVE_LONG_LONG
160-
if (navailsects <= (0x55555555 - (1 << (fmt->ff_clustshift + 1))))
161-
{
162-
#endif
163-
164-
denom = (fmt->ff_nfats << 1) + fmt->ff_nfats
165-
+ (var->fv_sectorsize << (fmt->ff_clustshift + 1));
166-
number = (navailsects << 1) + navailsects
167-
+ (1 << (fmt->ff_clustshift + 2))
168-
+ (1 << (fmt->ff_clustshift + 1));
169-
return (uint32_t)((number + denom - 1) / denom);
170-
171-
#ifndef CONFIG_HAVE_LONG_LONG
172-
}
173-
else
174-
{
175-
return 0;
176-
}
177-
#endif
154+
denom = (fmt->ff_nfats << 1) + fmt->ff_nfats
155+
+ (var->fv_sectorsize << (fmt->ff_clustshift + 1));
156+
number = (navailsects << 1) + navailsects
157+
+ (1 << (fmt->ff_clustshift + 2))
158+
+ (1 << (fmt->ff_clustshift + 1));
159+
return (uint32_t)((number + denom - 1) / denom);
178160
}
179161

180162
/****************************************************************************
@@ -201,13 +183,8 @@ static inline uint32_t
201183
mkfatfs_nfatsect16(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var,
202184
uint32_t navailsects)
203185
{
204-
#ifdef CONFIG_HAVE_LONG_LONG
205186
uint64_t denom;
206187
uint64_t number;
207-
#else
208-
uint32_t denom;
209-
uint32_t number;
210-
#endif
211188

212189
/* For FAT16, the cluster number is held in a 16-bit number or 2 bytes per
213190
* cluster reference. So each FAT sector will hold sectorsize/2 cluster
@@ -270,13 +247,8 @@ static inline uint32_t
270247
mkfatfs_nfatsect32(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var,
271248
uint32_t navailsects)
272249
{
273-
#ifdef CONFIG_HAVE_LONG_LONG
274250
uint64_t denom;
275251
uint64_t number;
276-
#else
277-
uint32_t denom;
278-
uint32_t number;
279-
#endif
280252

281253
/* For FAT32, the cluster number is held in a 32-bit number or 4 bytes per
282254
* cluster reference. So each FAT sector will hold sectorsize/4 cluster

logging/nxscope/nxscope_chan.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ static int nxscope_put_vector(FAR uint8_t *buff, uint8_t type, FAR void *val,
332332
break;
333333
}
334334

335-
#ifdef CONFIG_HAVE_LONG_LONG
336335
case NXSCOPE_TYPE_UINT64:
337336
case NXSCOPE_TYPE_INT64:
338337
case NXSCOPE_TYPE_DOUBLE:
@@ -358,7 +357,6 @@ static int nxscope_put_vector(FAR uint8_t *buff, uint8_t type, FAR void *val,
358357

359358
break;
360359
}
361-
#endif
362360

363361
case NXSCOPE_TYPE_CHAR:
364362
{

netutils/ftpd/ftpd.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3735,11 +3735,7 @@ static int ftpd_command_appe(FAR struct ftpd_session_s *session)
37353735

37363736
static int ftpd_command_rest(FAR struct ftpd_session_s *session)
37373737
{
3738-
#ifdef CONFIG_HAVE_LONG_LONG
37393738
session->restartpos = (off_t)atoll(session->param);
3740-
#else
3741-
session->restartpos = (off_t)atoi(session->param);
3742-
#endif
37433739
session->flags |= FTPD_SESSIONFLAG_RESTARTPOS;
37443740

37453741
return ftpd_response(session->cmd.sd, session->txtimeout,

netutils/ntpclient/ntpclient.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@
6363

6464
/* Configuration ************************************************************/
6565

66-
#ifndef CONFIG_HAVE_LONG_LONG
67-
# error "64-bit integer support required for NTP client"
68-
#endif
69-
7066
#if defined(CONFIG_LIBC_NETDB) && !defined(CONFIG_NETUTILS_NTPCLIENT_SERVER)
7167
# error "CONFIG_NETUTILS_NTPCLIENT_SERVER must be provided"
7268
#endif

system/zmodem/host/nuttx/compiler.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@
219219

220220
/* GCC supports both types double and long long */
221221

222-
# define CONFIG_HAVE_LONG_LONG 1
223222
# define CONFIG_HAVE_FLOAT 1
224223
# define CONFIG_HAVE_DOUBLE 1
225224
# define CONFIG_HAVE_LONG_DOUBLE 1
@@ -323,7 +322,6 @@
323322

324323
/* SDCC does not support type long long or type double */
325324

326-
# undef CONFIG_HAVE_LONG_LONG
327325
# define CONFIG_HAVE_FLOAT 1
328326
# undef CONFIG_HAVE_DOUBLE
329327
# undef CONFIG_HAVE_LONG_DOUBLE
@@ -431,7 +429,6 @@
431429
* and simply do not support long long or double.
432430
*/
433431

434-
# undef CONFIG_HAVE_LONG_LONG
435432
# define CONFIG_HAVE_FLOAT 1
436433
# undef CONFIG_HAVE_DOUBLE
437434
# undef CONFIG_HAVE_LONG_DOUBLE
@@ -507,7 +504,6 @@
507504
# undef CONFIG_SMALL_MEMORY
508505
# undef CONFIG_LONG_IS_NOT_INT
509506
# undef CONFIG_PTR_IS_NOT_INT
510-
# undef CONFIG_HAVE_LONG_LONG
511507
# define CONFIG_HAVE_FLOAT 1
512508
# undef CONFIG_HAVE_DOUBLE
513509
# undef CONFIG_HAVE_LONG_DOUBLE

testing/fs/fstest/fstest_main.c

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static inline void fstest_randname(FAR struct fstest_ctx_s *ctx,
218218

219219
dirlen = strlen(ctx->mountdir);
220220

221-
/* Force the max filename lengh and also the min name len = 4 */
221+
/* Force the max filename length and also the min name len = 4 */
222222

223223
maxname = CONFIG_TESTING_FSTEST_MAXNAME - dirlen - 3;
224224
namelen = (rand() % maxname) + 4;
@@ -668,7 +668,6 @@ static inline int fstest_rdfile(FAR struct fstest_ctx_s *ctx,
668668
* Name: fstest_filesize
669669
****************************************************************************/
670670

671-
#ifdef CONFIG_HAVE_LONG_LONG
672671
static unsigned long long fstest_filesize(FAR struct fstest_ctx_s *ctx)
673672
{
674673
unsigned long long bytes_used;
@@ -688,27 +687,6 @@ static unsigned long long fstest_filesize(FAR struct fstest_ctx_s *ctx)
688687

689688
return bytes_used;
690689
}
691-
#else
692-
static unsigned long fstest_filesize(FAR struct fstest_ctx_s *ctx)
693-
{
694-
unsigned long bytes_used;
695-
FAR struct fstest_filedesc_s *file;
696-
int i;
697-
698-
bytes_used = 0;
699-
700-
for (i = 0; i < ctx->max_open; i++)
701-
{
702-
file = &ctx->files[i];
703-
if (file->name != NULL && !file->deleted)
704-
{
705-
bytes_used += file->len;
706-
}
707-
}
708-
709-
return bytes_used;
710-
}
711-
#endif
712690

713691
/****************************************************************************
714692
* Name: fstest_verifyfs
@@ -983,7 +961,7 @@ int main(int argc, FAR char *argv[])
983961
ctx = malloc(sizeof(struct fstest_ctx_s));
984962
if (ctx == NULL)
985963
{
986-
printf("malloc ctx feild,exit!\n");
964+
printf("malloc ctx field,exit!\n");
987965
exit(1);
988966
}
989967

@@ -1081,11 +1059,7 @@ int main(int argc, FAR char *argv[])
10811059
/* Directory listing */
10821060

10831061
fstest_directory(ctx);
1084-
#ifdef CONFIG_HAVE_LONG_LONG
10851062
printf("Total file size: %llu\n", fstest_filesize(ctx));
1086-
#else
1087-
printf("Total file size: %lu\n", fstest_filesize(ctx));
1088-
#endif
10891063

10901064
/* Verify all files written to FLASH */
10911065

@@ -1131,11 +1105,7 @@ int main(int argc, FAR char *argv[])
11311105
/* Directory listing */
11321106

11331107
fstest_directory(ctx);
1134-
#ifdef CONFIG_HAVE_LONG_LONG
11351108
printf("Total file size: %llu\n", fstest_filesize(ctx));
1136-
#else
1137-
printf("Total file size: %lu\n", fstest_filesize(ctx));
1138-
#endif
11391109

11401110
/* Verify all files written to FLASH */
11411111

0 commit comments

Comments
 (0)