-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsensortest.zig
5420 lines (5420 loc) · 255 KB
/
sensortest.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
pub const __builtin_bswap16 = @import("std").zig.c_builtins.__builtin_bswap16;
pub const __builtin_bswap32 = @import("std").zig.c_builtins.__builtin_bswap32;
pub const __builtin_bswap64 = @import("std").zig.c_builtins.__builtin_bswap64;
pub const __builtin_signbit = @import("std").zig.c_builtins.__builtin_signbit;
pub const __builtin_signbitf = @import("std").zig.c_builtins.__builtin_signbitf;
pub const __builtin_popcount = @import("std").zig.c_builtins.__builtin_popcount;
pub const __builtin_ctz = @import("std").zig.c_builtins.__builtin_ctz;
pub const __builtin_clz = @import("std").zig.c_builtins.__builtin_clz;
pub const __builtin_sqrt = @import("std").zig.c_builtins.__builtin_sqrt;
pub const __builtin_sqrtf = @import("std").zig.c_builtins.__builtin_sqrtf;
pub const __builtin_sin = @import("std").zig.c_builtins.__builtin_sin;
pub const __builtin_sinf = @import("std").zig.c_builtins.__builtin_sinf;
pub const __builtin_cos = @import("std").zig.c_builtins.__builtin_cos;
pub const __builtin_cosf = @import("std").zig.c_builtins.__builtin_cosf;
pub const __builtin_exp = @import("std").zig.c_builtins.__builtin_exp;
pub const __builtin_expf = @import("std").zig.c_builtins.__builtin_expf;
pub const __builtin_exp2 = @import("std").zig.c_builtins.__builtin_exp2;
pub const __builtin_exp2f = @import("std").zig.c_builtins.__builtin_exp2f;
pub const __builtin_log = @import("std").zig.c_builtins.__builtin_log;
pub const __builtin_logf = @import("std").zig.c_builtins.__builtin_logf;
pub const __builtin_log2 = @import("std").zig.c_builtins.__builtin_log2;
pub const __builtin_log2f = @import("std").zig.c_builtins.__builtin_log2f;
pub const __builtin_log10 = @import("std").zig.c_builtins.__builtin_log10;
pub const __builtin_log10f = @import("std").zig.c_builtins.__builtin_log10f;
pub const __builtin_abs = @import("std").zig.c_builtins.__builtin_abs;
pub const __builtin_fabs = @import("std").zig.c_builtins.__builtin_fabs;
pub const __builtin_fabsf = @import("std").zig.c_builtins.__builtin_fabsf;
pub const __builtin_floor = @import("std").zig.c_builtins.__builtin_floor;
pub const __builtin_floorf = @import("std").zig.c_builtins.__builtin_floorf;
pub const __builtin_ceil = @import("std").zig.c_builtins.__builtin_ceil;
pub const __builtin_ceilf = @import("std").zig.c_builtins.__builtin_ceilf;
pub const __builtin_trunc = @import("std").zig.c_builtins.__builtin_trunc;
pub const __builtin_truncf = @import("std").zig.c_builtins.__builtin_truncf;
pub const __builtin_round = @import("std").zig.c_builtins.__builtin_round;
pub const __builtin_roundf = @import("std").zig.c_builtins.__builtin_roundf;
pub const __builtin_strlen = @import("std").zig.c_builtins.__builtin_strlen;
pub const __builtin_strcmp = @import("std").zig.c_builtins.__builtin_strcmp;
pub const __builtin_object_size = @import("std").zig.c_builtins.__builtin_object_size;
pub const __builtin___memset_chk = @import("std").zig.c_builtins.__builtin___memset_chk;
pub const __builtin_memset = @import("std").zig.c_builtins.__builtin_memset;
pub const __builtin___memcpy_chk = @import("std").zig.c_builtins.__builtin___memcpy_chk;
pub const __builtin_memcpy = @import("std").zig.c_builtins.__builtin_memcpy;
pub const __builtin_expect = @import("std").zig.c_builtins.__builtin_expect;
pub const __builtin_nanf = @import("std").zig.c_builtins.__builtin_nanf;
pub const __builtin_huge_valf = @import("std").zig.c_builtins.__builtin_huge_valf;
pub const __builtin_inff = @import("std").zig.c_builtins.__builtin_inff;
pub const __builtin_isnan = @import("std").zig.c_builtins.__builtin_isnan;
pub const __builtin_isinf = @import("std").zig.c_builtins.__builtin_isinf;
pub const __builtin_isinf_sign = @import("std").zig.c_builtins.__builtin_isinf_sign;
pub const __has_builtin = @import("std").zig.c_builtins.__has_builtin;
pub const __builtin_assume = @import("std").zig.c_builtins.__builtin_assume;
pub const __builtin_unreachable = @import("std").zig.c_builtins.__builtin_unreachable;
pub const __builtin_constant_p = @import("std").zig.c_builtins.__builtin_constant_p;
pub const __builtin_mul_overflow = @import("std").zig.c_builtins.__builtin_mul_overflow;
pub const _int8_t = i8;
pub const _uint8_t = u8;
pub const _int16_t = c_short;
pub const _uint16_t = c_ushort;
pub const _int32_t = c_long;
pub const _uint32_t = c_ulong;
pub const _int64_t = c_longlong;
pub const _uint64_t = c_ulonglong;
pub const _intmax_t = _int64_t;
pub const _uintmax_t = _uint64_t;
pub const _wchar_t = c_int;
pub const _ssize_t = c_int;
pub const _size_t = c_uint;
pub const irqstate_t = c_uint;
pub const int_least64_t = i64;
pub const uint_least64_t = u64;
pub const int_fast64_t = i64;
pub const uint_fast64_t = u64;
pub const int_least32_t = i32;
pub const uint_least32_t = u32;
pub const int_fast32_t = i32;
pub const uint_fast32_t = u32;
pub const int_least16_t = i16;
pub const uint_least16_t = u16;
pub const int_fast16_t = i16;
pub const uint_fast16_t = u16;
pub const int_least8_t = i8;
pub const uint_least8_t = u8;
pub const int_fast8_t = i8;
pub const uint_fast8_t = u8;
pub const intmax_t = c_longlong;
pub const uintmax_t = c_ulonglong;
pub const mode_t = c_uint;
pub const rsize_t = _size_t;
pub const uid_t = i16;
pub const gid_t = i16;
pub const dev_t = u32;
pub const ino_t = u16;
pub const nlink_t = u16;
pub const pid_t = c_int;
pub const id_t = c_int;
pub const key_t = i32;
pub const ptrdiff_t = isize;
pub const wchar_t = _wchar_t;
pub const wint_t = c_int;
pub const wctype_t = c_int;
pub const fsblkcnt_t = u32;
pub const fsfilcnt_t = u32;
pub const blkcnt_t = u32;
pub const off_t = i32;
pub const fpos_t = i32;
pub const blksize_t = i16;
pub const socklen_t = c_uint;
pub const sa_family_t = u16;
pub const clock_t = u32;
pub const useconds_t = u32;
pub const suseconds_t = i32;
pub const cpu_set_t = u8;
pub const u_char = u8;
pub const u_short = c_ushort;
pub const u_int = c_uint;
pub const u_long = c_ulong;
pub const unchar = u8;
pub const ushort = c_ushort;
pub const uint = c_uint;
pub const ulong = c_ulong;
pub const s_char = i8;
pub const caddr_t = [*c]u8;
pub const u_int8_t = u8;
pub const u_int16_t = u16;
pub const u_int32_t = u32;
pub const u_int64_t = u64;
pub const main_t = ?fn (c_int, [*c][*c]u8) callconv(.C) c_int;
pub const ERROR: c_int = -1;
pub const OK: c_int = 0;
const enum_unnamed_1 = c_int;
pub const time_t = u32;
pub const clockid_t = u8;
pub const timer_t = ?*anyopaque;
pub const struct_timespec = extern struct {
tv_sec: time_t,
tv_nsec: c_long,
};
pub const struct_tm = extern struct {
tm_sec: c_int,
tm_min: c_int,
tm_hour: c_int,
tm_mday: c_int,
tm_mon: c_int,
tm_year: c_int,
tm_wday: c_int,
tm_yday: c_int,
tm_isdst: c_int,
tm_gmtoff: c_long,
tm_zone: [*c]const u8,
};
pub const struct_itimerspec = extern struct {
it_interval: struct_timespec,
it_value: struct_timespec,
};
pub const union_sigval = extern union {
sival_int: c_int,
sival_ptr: ?*anyopaque,
};
pub const sigev_notify_function_t = ?fn (union_sigval) callconv(.C) void;
pub const struct_pthread_attr_s = extern struct {
priority: u8,
policy: u8,
inheritsched: u8,
detachstate: u8,
stackaddr: ?*anyopaque,
stacksize: usize,
};
pub const pthread_attr_t = struct_pthread_attr_s;
pub const struct_sigevent = extern struct {
sigev_notify: u8,
sigev_signo: u8,
sigev_value: union_sigval,
sigev_notify_function: sigev_notify_function_t,
sigev_notify_attributes: [*c]pthread_attr_t,
};
pub extern fn clock() clock_t;
pub extern fn clock_settime(clockid: clockid_t, tp: [*c]const struct_timespec) c_int;
pub extern fn clock_gettime(clockid: clockid_t, tp: [*c]struct_timespec) c_int;
pub extern fn clock_getres(clockid: clockid_t, res: [*c]struct_timespec) c_int;
pub extern fn timespec_get(t: [*c]struct_timespec, b: c_int) c_int;
pub extern fn timegm(tp: [*c]struct_tm) time_t;
pub extern fn mktime(tp: [*c]struct_tm) time_t;
pub extern fn gmtime(timep: [*c]const time_t) [*c]struct_tm;
pub extern fn gmtime_r(timep: [*c]const time_t, result: [*c]struct_tm) [*c]struct_tm;
pub extern fn localtime(timep: [*c]const time_t) [*c]struct_tm;
pub extern fn localtime_r(timep: [*c]const time_t, result: [*c]struct_tm) [*c]struct_tm;
pub extern fn strftime(s: [*c]u8, max: usize, format: [*c]const u8, tm: [*c]const struct_tm) usize;
pub extern fn strptime(s: [*c]const u8, format: [*c]const u8, tm: [*c]struct_tm) [*c]u8;
pub extern fn asctime(tp: [*c]const struct_tm) [*c]u8;
pub extern fn asctime_r(tp: [*c]const struct_tm, buf: [*c]u8) [*c]u8;
pub extern fn ctime(timep: [*c]const time_t) [*c]u8;
pub extern fn ctime_r(timep: [*c]const time_t, buf: [*c]u8) [*c]u8;
pub extern fn time(timep: [*c]time_t) time_t;
pub extern fn difftime(time1: time_t, time0: time_t) f64;
pub extern fn timer_create(clockid: clockid_t, evp: [*c]struct_sigevent, timerid: [*c]timer_t) c_int;
pub extern fn timer_delete(timerid: timer_t) c_int;
pub extern fn timer_settime(timerid: timer_t, flags: c_int, value: [*c]const struct_itimerspec, ovalue: [*c]struct_itimerspec) c_int;
pub extern fn timer_gettime(timerid: timer_t, value: [*c]struct_itimerspec) c_int;
pub extern fn timer_getoverrun(timerid: timer_t) c_int;
pub extern fn clock_nanosleep(clockid: clockid_t, flags: c_int, rqtp: [*c]const struct_timespec, rmtp: [*c]struct_timespec) c_int;
pub extern fn nanosleep(rqtp: [*c]const struct_timespec, rmtp: [*c]struct_timespec) c_int;
pub const __builtin_va_list = ?*anyopaque;
pub const va_list = __builtin_va_list;
pub const __gnuc_va_list = __builtin_va_list;
pub extern fn __errno() [*c]c_int;
pub extern fn _assert(filename: [*c]const u8, linenum: c_int) noreturn;
pub extern fn vfork() pid_t;
pub extern fn getpid() pid_t;
pub extern fn gettid() pid_t;
pub extern fn getppid() pid_t;
pub extern fn _exit(status: c_int) noreturn;
pub extern fn sleep(seconds: c_uint) c_uint;
pub extern fn usleep(usec: useconds_t) c_int;
pub extern fn pause() c_int;
pub extern fn nice(inc: c_int) c_int;
pub extern fn daemon(nochdir: c_int, noclose: c_int) c_int;
pub extern fn close(fd: c_int) c_int;
pub extern fn dup(fd: c_int) c_int;
pub extern fn dup2(fd1: c_int, fd2: c_int) c_int;
pub extern fn fsync(fd: c_int) c_int;
pub extern fn lseek(fd: c_int, offset: off_t, whence: c_int) off_t;
pub extern fn read(fd: c_int, buf: ?*anyopaque, nbytes: usize) isize;
pub extern fn write(fd: c_int, buf: ?*const anyopaque, nbytes: usize) isize;
pub extern fn pread(fd: c_int, buf: ?*anyopaque, nbytes: usize, offset: off_t) isize;
pub extern fn pwrite(fd: c_int, buf: ?*const anyopaque, nbytes: usize, offset: off_t) isize;
pub extern fn ftruncate(fd: c_int, length: off_t) c_int;
pub extern fn fchown(fd: c_int, owner: uid_t, group: gid_t) c_int;
pub extern fn isatty(fd: c_int) c_int;
pub extern fn ttyname(fd: c_int) [*c]u8;
pub extern fn ttyname_r(fd: c_int, buf: [*c]u8, buflen: usize) c_int;
pub extern fn pipe(fd: [*c]c_int) c_int;
pub extern fn pipe2(pipefd: [*c]c_int, flags: c_int) c_int;
pub extern fn alarm(seconds: c_uint) c_uint;
pub extern fn chdir(path: [*c]const u8) c_int;
pub extern fn getcwd(buf: [*c]u8, size: usize) [*c]u8;
pub extern fn access(path: [*c]const u8, amode: c_int) c_int;
pub extern fn rmdir(pathname: [*c]const u8) c_int;
pub extern fn unlink(pathname: [*c]const u8) c_int;
pub extern fn truncate(path: [*c]const u8, length: off_t) c_int;
pub extern fn symlink(path1: [*c]const u8, path2: [*c]const u8) c_int;
pub extern fn readlink(path: [*c]const u8, buf: [*c]u8, bufsize: usize) isize;
pub extern fn chown(path: [*c]const u8, owner: uid_t, group: gid_t) c_int;
pub extern fn lchown(path: [*c]const u8, owner: uid_t, group: gid_t) c_int;
pub extern fn swab(src: ?*const anyopaque, dest: ?*anyopaque, nbytes: isize) void;
pub extern fn getopt(argc: c_int, argv: [*c]const [*c]u8, optstring: [*c]const u8) c_int;
pub extern fn getoptargp() [*c][*c]u8;
pub extern fn getopterrp() [*c]c_int;
pub extern fn getoptindp() [*c]c_int;
pub extern fn getoptoptp() [*c]c_int;
pub extern fn gethostname(name: [*c]u8, namelen: usize) c_int;
pub extern fn sethostname(name: [*c]const u8, namelen: usize) c_int;
pub extern fn sysconf(name: c_int) c_long;
pub extern fn fpathconf(fildes: c_int, name: c_int) c_long;
pub extern fn pathconf(path: [*c]const u8, name: c_int) c_long;
pub extern fn setuid(uid: uid_t) c_int;
pub extern fn getuid() uid_t;
pub extern fn setgid(gid: gid_t) c_int;
pub extern fn getgid() gid_t;
pub extern fn seteuid(uid: uid_t) c_int;
pub extern fn geteuid() uid_t;
pub extern fn setegid(gid: gid_t) c_int;
pub extern fn getegid() gid_t;
pub extern fn setreuid(ruid: uid_t, euid: uid_t) c_int;
pub extern fn setregid(rgid: gid_t, egid: gid_t) c_int;
pub extern fn getentropy(buffer: ?*anyopaque, length: usize) c_int;
pub const struct_sem_s = extern struct {
semcount: i16,
};
pub const sem_t = struct_sem_s;
pub extern fn sem_init(sem: [*c]sem_t, pshared: c_int, value: c_uint) c_int;
pub extern fn sem_destroy(sem: [*c]sem_t) c_int;
pub extern fn sem_wait(sem: [*c]sem_t) c_int;
pub extern fn sem_timedwait(sem: [*c]sem_t, abstime: [*c]const struct_timespec) c_int;
pub extern fn sem_clockwait(sem: [*c]sem_t, clockid: clockid_t, abstime: [*c]const struct_timespec) c_int;
pub extern fn sem_trywait(sem: [*c]sem_t) c_int;
pub extern fn sem_post(sem: [*c]sem_t) c_int;
pub extern fn sem_getvalue(sem: [*c]sem_t, sval: [*c]c_int) c_int;
pub extern fn sem_setprotocol(sem: [*c]sem_t, protocol: c_int) c_int;
pub extern fn sem_getprotocol(sem: [*c]sem_t, protocol: [*c]c_int) c_int;
pub const sclock_t = i32;
pub extern var g_system_timer: clock_t;
pub extern fn clock_timespec_compare(ts1: [*c]const struct_timespec, ts2: [*c]const struct_timespec) c_int;
pub extern fn clock_timespec_add(ts1: [*c]const struct_timespec, ts2: [*c]const struct_timespec, ts3: [*c]struct_timespec) void;
pub extern fn clock_timespec_subtract(ts1: [*c]const struct_timespec, ts2: [*c]const struct_timespec, ts3: [*c]struct_timespec) void;
pub extern fn clock_time2ticks(reltime: [*c]const struct_timespec, ticks: [*c]sclock_t) c_int;
pub extern fn clock_ticks2time(ticks: sclock_t, reltime: [*c]struct_timespec) c_int;
pub extern fn clock_systime_timespec(ts: [*c]struct_timespec) c_int;
pub extern fn nxsem_init(sem: [*c]sem_t, pshared: c_int, value: c_uint) c_int;
pub extern fn nxsem_destroy(sem: [*c]sem_t) c_int;
pub extern fn nxsem_wait(sem: [*c]sem_t) c_int;
pub extern fn nxsem_trywait(sem: [*c]sem_t) c_int;
pub extern fn nxsem_timedwait(sem: [*c]sem_t, abstime: [*c]const struct_timespec) c_int;
pub extern fn nxsem_clockwait(sem: [*c]sem_t, clockid: clockid_t, abstime: [*c]const struct_timespec) c_int;
pub extern fn nxsem_tickwait(sem: [*c]sem_t, delay: u32) c_int;
pub extern fn nxsem_post(sem: [*c]sem_t) c_int;
pub extern fn nxsem_get_value(sem: [*c]sem_t, sval: [*c]c_int) c_int;
pub extern fn nxsem_reset(sem: [*c]sem_t, count: i16) c_int;
pub extern fn nxsem_set_protocol(sem: [*c]sem_t, protocol: c_int) c_int;
pub extern fn nxsem_wait_uninterruptible(sem: [*c]sem_t) c_int;
pub extern fn nxsem_timedwait_uninterruptible(sem: [*c]sem_t, abstime: [*c]const struct_timespec) c_int;
pub extern fn nxsem_clockwait_uninterruptible(sem: [*c]sem_t, clockid: clockid_t, abstime: [*c]const struct_timespec) c_int;
pub extern fn nxsem_tickwait_uninterruptible(sem: [*c]sem_t, delay: u32) c_int;
pub const mutex_t = sem_t;
pub const struct_rmutex_s = extern struct {
mutex: mutex_t,
holder: pid_t,
count: u16,
};
pub const rmutex_t = struct_rmutex_s;
pub fn nxmutex_init(arg_mutex: [*c]mutex_t) callconv(.C) c_int {
var mutex = arg_mutex;
var ret: c_int = sem_init(mutex, @as(c_int, 0), @bitCast(c_uint, @as(c_int, 1)));
if (ret < @as(c_int, 0)) {
return -__errno().*;
}
return ret;
}
pub fn nxmutex_destroy(arg_mutex: [*c]mutex_t) callconv(.C) c_int {
var mutex = arg_mutex;
var ret: c_int = sem_destroy(mutex);
if (ret < @as(c_int, 0)) {
return -__errno().*;
}
return ret;
}
pub fn nxmutex_lock(arg_mutex: [*c]mutex_t) callconv(.C) c_int {
var mutex = arg_mutex;
var ret: c_int = undefined;
while (true) {
ret = sem_wait(mutex);
if (ret >= @as(c_int, 0)) {
break;
}
ret = -__errno().*;
if ((ret != -@as(c_int, 4)) and (ret != -@as(c_int, 140))) {
break;
}
}
return ret;
}
pub fn nxmutex_trylock(arg_mutex: [*c]mutex_t) callconv(.C) c_int {
var mutex = arg_mutex;
var ret: c_int = sem_trywait(mutex);
if (ret < @as(c_int, 0)) {
return -__errno().*;
}
return ret;
}
pub fn nxmutex_is_locked(arg_mutex: [*c]mutex_t) callconv(.C) bool {
var mutex = arg_mutex;
var cnt: c_int = undefined;
var ret: c_int = undefined;
ret = sem_getvalue(mutex, &cnt);
{
if (!(ret == OK)) {
_assert("/home/user/nuttx/nuttx/include/nuttx/mutex.h", @as(c_int, 230));
}
}
return cnt < @as(c_int, 1);
}
pub fn nxmutex_unlock(arg_mutex: [*c]mutex_t) callconv(.C) c_int {
var mutex = arg_mutex;
var ret: c_int = undefined;
ret = sem_post(mutex);
if (ret < @as(c_int, 0)) {
return -__errno().*;
}
return ret;
}
pub fn nxrmutex_init(arg_rmutex: [*c]rmutex_t) callconv(.C) c_int {
var rmutex = arg_rmutex;
rmutex.*.count = 0;
rmutex.*.holder = @bitCast(pid_t, -@as(c_int, 1));
return nxmutex_init(&rmutex.*.mutex);
}
pub fn nxrmutex_destroy(arg_rmutex: [*c]rmutex_t) callconv(.C) c_int {
var rmutex = arg_rmutex;
return nxmutex_destroy(&rmutex.*.mutex);
}
pub fn nxrmutex_lock(arg_rmutex: [*c]rmutex_t) callconv(.C) c_int {
var rmutex = arg_rmutex;
var tid: pid_t = gettid();
var ret: c_int = undefined;
if (rmutex.*.holder == tid) {
{
if (!(@bitCast(c_uint, @as(c_uint, rmutex.*.count)) < @as(c_uint, 65535))) {
_assert("/home/user/nuttx/nuttx/include/nuttx/mutex.h", @as(c_int, 342));
}
}
rmutex.*.count +%= 1;
ret = OK;
} else {
ret = nxmutex_lock(&rmutex.*.mutex);
if (ret == OK) {
rmutex.*.holder = tid;
rmutex.*.count = 1;
}
}
return ret;
}
pub fn nxrmutex_trylock(arg_rmutex: [*c]rmutex_t) callconv(.C) c_int {
var rmutex = arg_rmutex;
var tid: pid_t = gettid();
var ret: c_int = undefined;
if (rmutex.*.holder == tid) {
{
if (!(@bitCast(c_uint, @as(c_uint, rmutex.*.count)) < @as(c_uint, 65535))) {
_assert("/home/user/nuttx/nuttx/include/nuttx/mutex.h", @as(c_int, 389));
}
}
rmutex.*.count +%= 1;
ret = OK;
} else {
ret = nxmutex_trylock(&rmutex.*.mutex);
if (ret == OK) {
rmutex.*.holder = tid;
rmutex.*.count = 1;
}
}
return ret;
}
pub fn nxrmutex_is_locked(arg_rmutex: [*c]rmutex_t) callconv(.C) bool {
var rmutex = arg_rmutex;
return @bitCast(c_int, @as(c_uint, rmutex.*.count)) > @as(c_int, 0);
}
pub fn nxrmutex_is_hold(arg_rmutex: [*c]rmutex_t) callconv(.C) bool {
var rmutex = arg_rmutex;
return rmutex.*.holder == gettid();
}
pub fn nxrmutex_unlock(arg_rmutex: [*c]rmutex_t) callconv(.C) c_int {
var rmutex = arg_rmutex;
var tid: pid_t = gettid();
var ret: c_int = OK;
{
if (!(rmutex.*.holder == tid)) {
_assert("/home/user/nuttx/nuttx/include/nuttx/mutex.h", @as(c_int, 470));
}
}
{
if (!(@bitCast(c_int, @as(c_uint, rmutex.*.count)) > @as(c_int, 0))) {
_assert("/home/user/nuttx/nuttx/include/nuttx/mutex.h", @as(c_int, 471));
}
}
if (@bitCast(c_int, @as(c_uint, rmutex.*.count)) == @as(c_int, 1)) {
rmutex.*.count = 0;
rmutex.*.holder = @bitCast(pid_t, -@as(c_int, 1));
ret = nxmutex_unlock(&rmutex.*.mutex);
} else {
rmutex.*.count -%= 1;
}
return ret;
}
pub const pollevent_t = u32;
pub const struct_pollfd = extern struct {
fd: c_int,
events: pollevent_t,
revents: pollevent_t,
ptr: ?*anyopaque,
sem: [*c]sem_t,
priv: ?*anyopaque,
};
pub const struct_file_operations = extern struct {
open: ?fn ([*c]struct_file) callconv(.C) c_int,
close: ?fn ([*c]struct_file) callconv(.C) c_int,
read: ?fn ([*c]struct_file, [*c]u8, usize) callconv(.C) isize,
write: ?fn ([*c]struct_file, [*c]const u8, usize) callconv(.C) isize,
seek: ?fn ([*c]struct_file, off_t, c_int) callconv(.C) off_t,
ioctl: ?fn ([*c]struct_file, c_int, c_ulong) callconv(.C) c_int,
poll: ?fn ([*c]struct_file, [*c]struct_pollfd, bool) callconv(.C) c_int,
};
pub const struct_geometry = extern struct {
geo_available: bool,
geo_mediachanged: bool,
geo_writeenabled: bool,
geo_nsectors: blkcnt_t,
geo_sectorsize: blksize_t,
};
pub const struct_block_operations = extern struct {
open: ?fn ([*c]struct_inode) callconv(.C) c_int,
close: ?fn ([*c]struct_inode) callconv(.C) c_int,
read: ?fn ([*c]struct_inode, [*c]u8, blkcnt_t, c_uint) callconv(.C) isize,
write: ?fn ([*c]struct_inode, [*c]const u8, blkcnt_t, c_uint) callconv(.C) isize,
geometry: ?fn ([*c]struct_inode, [*c]struct_geometry) callconv(.C) c_int,
ioctl: ?fn ([*c]struct_inode, c_int, c_ulong) callconv(.C) c_int,
};
pub const struct_mtd_dev_s = opaque {};
pub const struct_stat = opaque {};
pub const struct_fs_dirent_s = opaque {};
pub const struct_statfs = opaque {};
pub const struct_mountpt_operations = extern struct {
open: ?fn ([*c]struct_file, [*c]const u8, c_int, mode_t) callconv(.C) c_int,
close: ?fn ([*c]struct_file) callconv(.C) c_int,
read: ?fn ([*c]struct_file, [*c]u8, usize) callconv(.C) isize,
write: ?fn ([*c]struct_file, [*c]const u8, usize) callconv(.C) isize,
seek: ?fn ([*c]struct_file, off_t, c_int) callconv(.C) off_t,
ioctl: ?fn ([*c]struct_file, c_int, c_ulong) callconv(.C) c_int,
sync: ?fn ([*c]struct_file) callconv(.C) c_int,
dup: ?fn ([*c]const struct_file, [*c]struct_file) callconv(.C) c_int,
fstat: ?fn ([*c]const struct_file, ?*struct_stat) callconv(.C) c_int,
fchstat: ?fn ([*c]const struct_file, ?*const struct_stat, c_int) callconv(.C) c_int,
truncate: ?fn ([*c]struct_file, off_t) callconv(.C) c_int,
opendir: ?fn ([*c]struct_inode, [*c]const u8, ?*struct_fs_dirent_s) callconv(.C) c_int,
closedir: ?fn ([*c]struct_inode, ?*struct_fs_dirent_s) callconv(.C) c_int,
readdir: ?fn ([*c]struct_inode, ?*struct_fs_dirent_s) callconv(.C) c_int,
rewinddir: ?fn ([*c]struct_inode, ?*struct_fs_dirent_s) callconv(.C) c_int,
bind: ?fn ([*c]struct_inode, ?*const anyopaque, [*c]?*anyopaque) callconv(.C) c_int,
unbind: ?fn (?*anyopaque, [*c][*c]struct_inode, c_uint) callconv(.C) c_int,
statfs: ?fn ([*c]struct_inode, ?*struct_statfs) callconv(.C) c_int,
unlink: ?fn ([*c]struct_inode, [*c]const u8) callconv(.C) c_int,
mkdir: ?fn ([*c]struct_inode, [*c]const u8, mode_t) callconv(.C) c_int,
rmdir: ?fn ([*c]struct_inode, [*c]const u8) callconv(.C) c_int,
rename: ?fn ([*c]struct_inode, [*c]const u8, [*c]const u8) callconv(.C) c_int,
stat: ?fn ([*c]struct_inode, [*c]const u8, ?*struct_stat) callconv(.C) c_int,
chstat: ?fn ([*c]struct_inode, [*c]const u8, ?*const struct_stat, c_int) callconv(.C) c_int,
};
pub const union_inode_ops_u = extern union {
i_ops: [*c]const struct_file_operations,
i_bops: [*c]const struct_block_operations,
i_mtd: ?*struct_mtd_dev_s,
i_mops: [*c]const struct_mountpt_operations,
};
pub const struct_inode = extern struct {
i_parent: [*c]struct_inode,
i_peer: [*c]struct_inode,
i_child: [*c]struct_inode,
i_crefs: i16,
i_flags: u16,
u: union_inode_ops_u,
i_private: ?*anyopaque,
i_name: [1]u8,
};
pub const struct_file = extern struct {
f_oflags: c_int,
f_pos: off_t,
f_inode: [*c]struct_inode,
f_priv: ?*anyopaque,
};
pub const struct_partition_info_s = extern struct {
numsectors: usize,
sectorsize: usize,
startsector: off_t,
parent: [33]u8,
};
pub const struct_filelist = extern struct {
fl_sem: sem_t,
fl_rows: u8,
fl_files: [*c][*c]struct_file,
};
pub const struct_file_struct = extern struct {
fs_next: [*c]struct_file_struct,
fs_fd: c_int,
fs_oflags: u16,
fs_flags: u8,
fs_nungotten: u8,
fs_ungotten: [2]u8,
};
pub const struct_streamlist = extern struct {
sl_sem: sem_t,
sl_std: [3]struct_file_struct,
sl_head: [*c]struct_file_struct,
sl_tail: [*c]struct_file_struct,
};
pub extern fn fs_initialize() void;
pub extern fn register_driver(path: [*c]const u8, fops: [*c]const struct_file_operations, mode: mode_t, priv: ?*anyopaque) c_int;
pub extern fn register_blockdriver(path: [*c]const u8, bops: [*c]const struct_block_operations, mode: mode_t, priv: ?*anyopaque) c_int;
pub extern fn register_blockpartition(partition: [*c]const u8, mode: mode_t, parent: [*c]const u8, firstsector: off_t, nsectors: off_t) c_int;
pub extern fn unregister_driver(path: [*c]const u8) c_int;
pub extern fn unregister_blockdriver(path: [*c]const u8) c_int;
pub extern fn nx_mount(source: [*c]const u8, target: [*c]const u8, filesystemtype: [*c]const u8, mountflags: c_ulong, data: ?*const anyopaque) c_int;
pub extern fn nx_umount2(target: [*c]const u8, flags: c_uint) c_int;
pub extern fn files_initlist(list: [*c]struct_filelist) void;
pub extern fn files_releaselist(list: [*c]struct_filelist) void;
pub extern fn files_duplist(plist: [*c]struct_filelist, clist: [*c]struct_filelist) c_int;
pub extern fn file_dup(filep: [*c]struct_file, minfd: c_int) c_int;
pub extern fn nx_dup(fd: c_int) c_int;
pub extern fn file_dup2(filep1: [*c]struct_file, filep2: [*c]struct_file) c_int;
pub extern fn nx_dup2(fd1: c_int, fd2: c_int) c_int;
pub extern fn file_open(filep: [*c]struct_file, path: [*c]const u8, oflags: c_int, ...) c_int;
pub extern fn nx_open(path: [*c]const u8, oflags: c_int, ...) c_int;
pub extern fn fs_getfilep(fd: c_int, filep: [*c][*c]struct_file) c_int;
pub extern fn file_close(filep: [*c]struct_file) c_int;
pub extern fn nx_close(fd: c_int) c_int;
pub extern fn open_blockdriver(pathname: [*c]const u8, mountflags: c_int, ppinode: [*c][*c]struct_inode) c_int;
pub extern fn close_blockdriver(inode: [*c]struct_inode) c_int;
pub const struct_join_s = opaque {};
pub const struct_task_info_s = opaque {};
pub const struct_sq_entry_s = extern struct {
flink: [*c]struct_sq_entry_s,
};
pub const sq_entry_t = struct_sq_entry_s;
pub const struct_sq_queue_s = extern struct {
head: [*c]sq_entry_t,
tail: [*c]sq_entry_t,
};
pub const sq_queue_t = struct_sq_queue_s;
pub const struct_task_group_s = extern struct {
tg_pid: pid_t,
tg_ppid: pid_t,
tg_flags: u8,
tg_nmembers: u8,
tg_nwaiters: u8,
tg_waitflags: u8,
tg_exitsem: sem_t,
tg_statloc: [*c]c_int,
tg_joinsem: sem_t,
tg_joinhead: ?*struct_join_s,
tg_jointail: ?*struct_join_s,
tg_info: ?*struct_task_info_s,
tg_sigactionq: sq_queue_t,
tg_sigpendingq: sq_queue_t,
itimer: timer_t,
tg_filelist: struct_filelist,
tg_streamlist: struct_streamlist,
};
pub const start_t = ?fn () callconv(.C) void;
pub const pthread_addr_t = ?*anyopaque;
pub const pthread_startroutine_t = ?fn (pthread_addr_t) callconv(.C) pthread_addr_t;
pub const union_entry_u = extern union {
pthread: pthread_startroutine_t,
sensortest_main: main_t,
};
pub const entry_t = union_entry_u;
pub const wdparm_t = usize;
pub const wdentry_t = ?fn (wdparm_t) callconv(.C) void;
pub const struct_wdog_s = extern struct {
next: [*c]struct_wdog_s,
func: wdentry_t,
lag: sclock_t,
arg: wdparm_t,
};
pub const sigset_t = u32;
pub const struct_siginfo = extern struct {
si_signo: u8,
si_code: u8,
si_errno: u8,
si_value: union_sigval,
};
pub const siginfo_t = struct_siginfo;
pub const struct_mqueue_inode_s = opaque {};
pub const struct_xcptcontext = extern struct {
sigdeliver: ?*anyopaque,
saved_regs: [*c]usize,
regs: [*c]usize,
};
pub const struct_tcb_s = extern struct {
flink: [*c]struct_tcb_s,
blink: [*c]struct_tcb_s,
group: [*c]struct_task_group_s,
pid: pid_t,
sched_priority: u8,
init_priority: u8,
start: start_t,
entry: entry_t,
task_state: u8,
flags: u16,
lockcount: i16,
errcode: i16,
timeslice: i32,
waitdog: struct_wdog_s,
adj_stack_size: usize,
stack_alloc_ptr: ?*anyopaque,
stack_base_ptr: ?*anyopaque,
waitsem: [*c]sem_t,
sigprocmask: sigset_t,
sigwaitmask: sigset_t,
sigpendactionq: sq_queue_t,
sigpostedq: sq_queue_t,
sigunbinfo: siginfo_t,
msgwaitq: ?*struct_mqueue_inode_s,
xcp: struct_xcptcontext,
name: [13]u8,
};
pub extern fn fs_fdopen(fd: c_int, oflags: c_int, tcb: [*c]struct_tcb_s, filep: [*c][*c]struct_file_struct) c_int;
pub extern fn lib_flushall(list: [*c]struct_streamlist) c_int;
pub extern fn file_read(filep: [*c]struct_file, buf: ?*anyopaque, nbytes: usize) isize;
pub extern fn nx_read(fd: c_int, buf: ?*anyopaque, nbytes: usize) isize;
pub extern fn file_write(filep: [*c]struct_file, buf: ?*const anyopaque, nbytes: usize) isize;
pub extern fn nx_write(fd: c_int, buf: ?*const anyopaque, nbytes: usize) isize;
pub extern fn file_pread(filep: [*c]struct_file, buf: ?*anyopaque, nbytes: usize, offset: off_t) isize;
pub extern fn file_pwrite(filep: [*c]struct_file, buf: ?*const anyopaque, nbytes: usize, offset: off_t) isize;
pub extern fn file_sendfile(outfile: [*c]struct_file, infile: [*c]struct_file, offset: [*c]off_t, count: usize) isize;
pub extern fn file_seek(filep: [*c]struct_file, offset: off_t, whence: c_int) off_t;
pub extern fn nx_seek(fd: c_int, offset: off_t, whence: c_int) off_t;
pub extern fn file_fsync(filep: [*c]struct_file) c_int;
pub extern fn file_truncate(filep: [*c]struct_file, length: off_t) c_int;
pub extern fn file_mmap(filep: [*c]struct_file, start: ?*anyopaque, length: usize, prot: c_int, flags: c_int, offset: off_t, mapped: [*c]?*anyopaque) c_int;
pub extern fn file_munmap(start: ?*anyopaque, length: usize) c_int;
pub extern fn file_ioctl(filep: [*c]struct_file, req: c_int, ...) c_int;
pub extern fn nx_ioctl(fd: c_int, req: c_int, ...) c_int;
pub extern fn file_fcntl(filep: [*c]struct_file, cmd: c_int, ...) c_int;
pub extern fn nx_fcntl(fd: c_int, cmd: c_int, ...) c_int;
pub extern fn file_poll(filep: [*c]struct_file, fds: [*c]struct_pollfd, setup: bool) c_int;
pub extern fn nx_poll(fds: [*c]struct_pollfd, nfds: c_uint, timeout: c_int) c_int;
pub extern fn file_fstat(filep: [*c]struct_file, buf: ?*struct_stat) c_int;
pub extern fn nx_stat(path: [*c]const u8, buf: ?*struct_stat, resolve: c_int) c_int;
pub extern fn file_fchstat(filep: [*c]struct_file, buf: ?*struct_stat, flags: c_int) c_int;
pub extern fn nx_unlink(pathname: [*c]const u8) c_int;
pub const struct_winsize = extern struct {
ws_row: u16,
ws_col: u16,
ws_xpixel: u16,
ws_ypixel: u16,
};
pub const struct_serial_rs485 = extern struct {
flags: u32,
delay_rts_before_send: u32,
delay_rts_after_send: u32,
};
pub fn sensor_get_timestamp() callconv(.C) u64 {
var ts: struct_timespec = undefined;
_ = clock_systime_timespec(&ts);
return (@as(c_ulonglong, 1000000) *% @bitCast(c_ulonglong, @as(c_ulonglong, ts.tv_sec))) +% @bitCast(c_ulonglong, @as(c_longlong, @divTrunc(ts.tv_nsec, @bitCast(c_long, @as(c_long, @as(c_int, 1000))))));
}
pub const struct_sensor_accel = extern struct {
timestamp: u64,
x: f32,
y: f32,
z: f32,
temperature: f32,
};
pub const struct_sensor_gyro = extern struct {
timestamp: u64,
x: f32,
y: f32,
z: f32,
temperature: f32,
};
pub const struct_sensor_mag = extern struct {
timestamp: u64,
x: f32,
y: f32,
z: f32,
temperature: f32,
};
pub const struct_sensor_baro = extern struct {
timestamp: u64,
pressure: f32,
temperature: f32,
};
pub const struct_sensor_prox = extern struct {
timestamp: u64,
proximity: f32,
};
pub const struct_sensor_light = extern struct {
timestamp: u64,
light: f32,
};
pub const struct_sensor_humi = extern struct {
timestamp: u64,
humidity: f32,
};
pub const struct_sensor_temp = extern struct {
timestamp: u64,
temperature: f32,
};
pub const struct_sensor_rgb = extern struct {
timestamp: u64,
r: f32,
g: f32,
b: f32,
};
pub const struct_sensor_hall = extern struct {
timestamp: u64,
hall: bool,
};
pub const struct_sensor_ir = extern struct {
timestamp: u64,
ir: f32,
};
pub const struct_sensor_gps = extern struct {
timestamp: u64,
time_utc: u64,
latitude: f32,
longitude: f32,
altitude: f32,
altitude_ellipsoid: f32,
eph: f32,
epv: f32,
hdop: f32,
vdop: f32,
ground_speed: f32,
course: f32,
satellites_used: u32,
};
pub const struct_sensor_uv = extern struct {
timestamp: u64,
uvi: f32,
};
pub const struct_sensor_noise = extern struct {
timestamp: u64,
db: f32,
};
pub const struct_sensor_pm25 = extern struct {
timestamp: u64,
pm25: f32,
};
pub const struct_sensor_pm10 = extern struct {
timestamp: u64,
pm10: f32,
};
pub const struct_sensor_pm1p0 = extern struct {
timestamp: u64,
pm1p0: f32,
};
pub const struct_sensor_co2 = extern struct {
timestamp: u64,
co2: f32,
};
pub const struct_sensor_hcho = extern struct {
timestamp: u64,
hcho: f32,
};
pub const struct_sensor_tvoc = extern struct {
timestamp: u64,
tvoc: f32,
};
pub const struct_sensor_ph = extern struct {
timestamp: u64,
ph: f32,
};
pub const struct_sensor_dust = extern struct {
timestamp: u64,
dust: f32,
};
pub const struct_sensor_hrate = extern struct {
timestamp: u64,
bpm: f32,
};
pub const struct_sensor_hbeat = extern struct {
timestamp: u64,
beat: f32,
};
pub const struct_sensor_ecg = extern struct {
timestamp: u64,
ecg: f32,
};
pub const struct_sensor_ppgd = extern struct {
timestamp: u64,
ppg: [2]u32,
current: u32,
gain: [2]u16,
};
pub const struct_sensor_ppgq = extern struct {
timestamp: u64,
ppg: [4]u32,
current: u32,
gain: [4]u16,
};
pub const struct_sensor_impd = extern struct {
timestamp: u64,
real: f32,
imag: f32,
};
pub const struct_sensor_ots = extern struct {
timestamp: u64,
x: i32,
y: i32,
};
pub const struct_satellite = extern struct {
svid: u32,
elevation: u32,
azimuth: u32,
snr: u32,
};
pub const struct_sensor_gps_satellite = extern struct {
timestamp: u64,
count: u32,
satellites: u32,
info: [4]struct_satellite,
};
pub const struct_sensor_wake_gesture = extern struct {
timestamp: u64,
event: u32,
};
pub const struct_sensor_cap = extern struct {
timestamp: u64,
status: i32,
rawdata: [4]i32,
};
pub const struct_sensor_ops_s = extern struct {
open: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file) callconv(.C) c_int,
close: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file) callconv(.C) c_int,
activate: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file, bool) callconv(.C) c_int,
set_interval: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file, [*c]c_ulong) callconv(.C) c_int,
batch: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file, [*c]c_ulong) callconv(.C) c_int,
fetch: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file, [*c]u8, usize) callconv(.C) c_int,
selftest: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file, c_ulong) callconv(.C) c_int,
set_calibvalue: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file, c_ulong) callconv(.C) c_int,
calibrate: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file, c_ulong) callconv(.C) c_int,
control: ?fn ([*c]struct_sensor_lowerhalf_s, [*c]struct_file, c_int, c_ulong) callconv(.C) c_int,
};
pub const sensor_push_event_t = ?fn (?*anyopaque, ?*const anyopaque, usize) callconv(.C) isize;
pub const sensor_notify_event_t = ?fn (?*anyopaque) callconv(.C) void;
const union_unnamed_2 = extern union {
push_event: sensor_push_event_t,
notify_event: sensor_notify_event_t,
};
pub const struct_sensor_lowerhalf_s = extern struct {
type: c_int,
nbuffer: c_ulong,
uncalibrated: bool,
ops: [*c]const struct_sensor_ops_s,
unnamed_0: union_unnamed_2,
sensor_lock: ?fn (?*anyopaque) callconv(.C) void,
sensor_unlock: ?fn (?*anyopaque) callconv(.C) void,
priv: ?*anyopaque,
persist: bool,
};
pub const struct_sensor_state_s = extern struct {
esize: c_ulong,
nbuffer: c_ulong,
min_latency: c_ulong,
min_interval: c_ulong,
nsubscribers: c_ulong,
nadvertisers: c_ulong,
generation: c_ulong,
priv: ?*anyopaque,
};
pub const struct_sensor_ustate_s = extern struct {
esize: c_ulong,
latency: c_ulong,
interval: c_ulong,
generation: c_ulong,
};
pub const struct_sensor_ioctl_s = extern struct {
len: usize,
data: [1]u8,
};
pub extern fn sensor_register(dev: [*c]struct_sensor_lowerhalf_s, devno: c_int) c_int;
pub extern fn sensor_custom_register(dev: [*c]struct_sensor_lowerhalf_s, path: [*c]const u8, esize: c_ulong) c_int;
pub extern fn sensor_unregister(dev: [*c]struct_sensor_lowerhalf_s, devno: c_int) void;
pub extern fn sensor_custom_unregister(dev: [*c]struct_sensor_lowerhalf_s, path: [*c]const u8) void;
pub extern fn ioctl(fd: c_int, req: c_int, ...) c_int;
pub const max_align_t = extern struct {
__clang_max_align_nonce1: c_longlong align(8),
__clang_max_align_nonce2: c_longdouble align(16),
};
pub const imaxdiv_t = ?*anyopaque;
pub extern fn imaxabs(j: intmax_t) intmax_t;
pub extern fn imaxdiv(number: intmax_t, denom: intmax_t) imaxdiv_t;
pub extern fn strtoimax(nptr: [*c]const u8, endptr: [*c][*c]u8, base: c_int) intmax_t;
pub extern fn strtoumax(nptr: [*c]const u8, endptr: [*c][*c]u8, base: c_int) uintmax_t;
pub extern fn wcstoimax(nptr: [*c]const wchar_t, endptr: [*c][*c]wchar_t, base: c_int) intmax_t;
pub extern fn wcstoumax(nptr: [*c]const wchar_t, endptr: [*c][*c]wchar_t, base: c_int) uintmax_t;
pub const struct_div_s = extern struct {
quot: c_int,
rem: c_int,
};
pub const div_t = struct_div_s;
pub const struct_ldiv_s = extern struct {
quot: c_long,
rem: c_long,
};
pub const ldiv_t = struct_ldiv_s;
pub const struct_lldiv_s = extern struct {
quot: c_long,
rem: c_long,
};
pub const lldiv_t = struct_lldiv_s;
pub extern fn srand(seed: c_uint) void;
pub extern fn rand() c_int;
pub extern fn random() c_long;
pub extern fn arc4random_buf(bytes: ?*anyopaque, nbytes: usize) void;
pub extern fn get_environ_ptr() [*c][*c]u8;
pub extern fn getenv(name: [*c]const u8) [*c]u8;
pub extern fn putenv(string: [*c]const u8) c_int;
pub extern fn clearenv() c_int;
pub extern fn setenv(name: [*c]const u8, value: [*c]const u8, overwrite: c_int) c_int;
pub extern fn unsetenv(name: [*c]const u8) c_int;
pub extern fn exit(status: c_int) noreturn;
pub extern fn abort() noreturn;
pub extern fn atexit(func: ?fn () callconv(.C) void) c_int;
pub extern fn on_exit(func: ?fn (c_int, ?*anyopaque) callconv(.C) void, arg: ?*anyopaque) c_int;
pub extern fn _Exit(status: c_int) noreturn;
pub extern fn system(cmd: [*c]const u8) c_int;
pub extern fn realpath(path: [*c]const u8, resolved: [*c]u8) [*c]u8;
pub extern fn strtol(nptr: [*c]const u8, endptr: [*c][*c]u8, base: c_int) c_long;
pub extern fn strtoul(nptr: [*c]const u8, endptr: [*c][*c]u8, base: c_int) c_ulong;
pub extern fn strtoll(nptr: [*c]const u8, endptr: [*c][*c]u8, base: c_int) c_longlong;
pub extern fn strtoull(nptr: [*c]const u8, endptr: [*c][*c]u8, base: c_int) c_ulonglong;
pub extern fn strtof(str: [*c]const u8, endptr: [*c][*c]u8) f32;
pub extern fn strtod(str: [*c]const u8, endptr: [*c][*c]u8) f64;
pub extern fn strtold(str: [*c]const u8, endptr: [*c][*c]u8) c_longdouble;
pub extern fn atoi(nptr: [*c]const u8) c_int;
pub extern fn atol(nptr: [*c]const u8) c_long;
pub extern fn atoll(nptr: [*c]const u8) c_longlong;
pub extern fn atof(nptr: [*c]const u8) f64;
pub extern fn itoa(val: c_int, str: [*c]u8, base: c_int) [*c]u8;
pub extern fn mblen(s: [*c]const u8, n: usize) c_int;
pub extern fn mbtowc(pwc: [*c]wchar_t, s: [*c]const u8, n: usize) c_int;
pub extern fn mbstowcs(dst: [*c]wchar_t, src: [*c]const u8, len: usize) usize;
pub extern fn wctomb(s: [*c]u8, wchar: wchar_t) c_int;
pub extern fn wcstombs(dst: [*c]u8, src: [*c]const wchar_t, len: usize) usize;
pub extern fn malloc(usize) ?*anyopaque;
pub extern fn valloc(usize) ?*anyopaque;
pub extern fn free(?*anyopaque) void;
pub extern fn realloc(?*anyopaque, usize) ?*anyopaque;
pub extern fn memalign(usize, usize) ?*anyopaque;
pub extern fn zalloc(usize) ?*anyopaque;
pub extern fn calloc(usize, usize) ?*anyopaque;