This source file includes following definitions.
- getloadavg
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 #include <config.h>
80
81
82 #include <stdlib.h>
83
84 #include <errno.h>
85 #include <stdio.h>
86
87 # include <sys/types.h>
88
89 # if HAVE_SYS_PARAM_H
90 # include <sys/param.h>
91 # endif
92
93 # include "intprops.h"
94
95 # if defined _WIN32 && ! defined __CYGWIN__ && ! defined WINDOWS32
96 # define WINDOWS32
97 # endif
98
99 # ifdef NeXT
100
101
102
103 # undef BSD
104
105
106
107 # undef FSCALE
108 # endif
109
110
111 # ifdef __GNU__
112 # undef BSD
113 # undef FSCALE
114 # endif
115
116
117
118
119
120
121
122 # if defined (HPUX) && !defined (hpux)
123 # define hpux
124 # endif
125
126 # if defined (__hpux) && !defined (hpux)
127 # define hpux
128 # endif
129
130 # if defined (__sun) && !defined (sun)
131 # define sun
132 # endif
133
134 # if defined (hp300) && !defined (hpux)
135 # define MORE_BSD
136 # endif
137
138 # if defined (__SVR4) && !defined (SVR4)
139 # define SVR4
140 # endif
141
142 # if (defined (sun) && defined (SVR4)) || defined (SOLARIS2)
143 # define SUNOS_5
144 # endif
145
146 # if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
147 # define OSF_ALPHA
148 # include <sys/mbuf.h>
149 # include <sys/socket.h>
150 # include <net/route.h>
151 # include <sys/table.h>
152
153 # undef sys
154 # endif
155
156 # if defined (__osf__) && (defined (mips) || defined (__mips__))
157 # define OSF_MIPS
158 # include <sys/table.h>
159 # endif
160
161
162
163 # ifndef LOAD_AVE_TYPE
164
165 # ifdef MORE_BSD
166 # define LOAD_AVE_TYPE long
167 # endif
168
169 # ifdef sun
170 # define LOAD_AVE_TYPE long
171 # endif
172
173 # ifdef sgi
174 # define LOAD_AVE_TYPE long
175 # endif
176
177 # ifdef SVR4
178 # define LOAD_AVE_TYPE long
179 # endif
180
181 # ifdef OSF_ALPHA
182 # define LOAD_AVE_TYPE long
183 # endif
184
185 # if defined _AIX && ! defined HAVE_LIBPERFSTAT
186 # define LOAD_AVE_TYPE long
187 # endif
188
189 # endif
190
191 # ifdef OSF_ALPHA
192
193
194 # undef FSCALE
195 # define FSCALE 1024.0
196 # endif
197
198
199 # ifndef FSCALE
200
201
202
203 # ifdef MORE_BSD
204 # define FSCALE 2048.0
205 # endif
206
207 # if defined (MIPS) || defined (SVR4)
208 # define FSCALE 256
209 # endif
210
211 # if defined (sgi)
212
213
214 # undef FSCALE
215 # define FSCALE 1000.0
216 # endif
217
218 # if defined _AIX && !defined HAVE_LIBPERFSTAT
219 # define FSCALE 65536.0
220 # endif
221
222 # endif
223
224 # if !defined (LDAV_CVT) && defined (FSCALE)
225 # define LDAV_CVT(n) (((double) (n)) / FSCALE)
226 # endif
227
228 # ifndef NLIST_STRUCT
229 # if HAVE_NLIST_H
230 # define NLIST_STRUCT
231 # endif
232 # endif
233
234 # if defined (sgi) || (defined (mips) && !defined (BSD))
235 # define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31))
236 # endif
237
238
239 # if !defined (KERNEL_FILE) && defined (hpux)
240 # define KERNEL_FILE "/hp-ux"
241 # endif
242
243 # if !defined (KERNEL_FILE) && (defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi))
244 # define KERNEL_FILE "/unix"
245 # endif
246
247
248 # if !defined (LDAV_SYMBOL) && (defined (hpux) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (_AIX) && !defined(HAVE_LIBPERFSTAT)))
249 # define LDAV_SYMBOL "avenrun"
250 # endif
251
252 # ifdef HAVE_UNISTD_H
253 # include <unistd.h>
254 # endif
255
256
257
258 # if !defined (LOAD_AVE_TYPE) && (defined (BSD) || defined (LDAV_CVT) || defined (KERNEL_FILE) || defined (LDAV_SYMBOL))
259 # define LOAD_AVE_TYPE double
260 # endif
261
262 # ifdef LOAD_AVE_TYPE
263
264 # ifndef __VMS
265 # if !(defined __linux__ || defined __ANDROID__)
266 # ifndef NLIST_STRUCT
267 # include <a.out.h>
268 # else
269 # include <nlist.h>
270 # endif
271
272 # ifdef SUNOS_5
273 # include <kvm.h>
274 # include <kstat.h>
275 # endif
276
277 # if defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC)
278 # include <sys/pstat.h>
279 # endif
280
281 # ifndef KERNEL_FILE
282 # define KERNEL_FILE "/vmunix"
283 # endif
284
285 # ifndef LDAV_SYMBOL
286 # define LDAV_SYMBOL "_avenrun"
287 # endif
288 # endif
289
290 # else
291
292 # ifndef eunice
293 # include <iodef.h>
294 # include <descrip.h>
295 # else
296 # include <vms/iodef.h>
297 # endif
298 # endif
299
300 # ifndef LDAV_CVT
301 # define LDAV_CVT(n) ((double) (n))
302 # endif
303
304 # endif
305
306 # if defined HAVE_LIBPERFSTAT
307 # include <sys/protosw.h>
308 # include <libperfstat.h>
309 # include <sys/proc.h>
310 # ifndef SBITS
311 # define SBITS 16
312 # endif
313 # endif
314
315 # if defined (__GNU__) && !defined (NeXT)
316
317
318
319 # define NeXT
320 # define host_self mach_host_self
321 # endif
322
323 # ifdef NeXT
324 # ifdef HAVE_MACH_MACH_H
325 # include <mach/mach.h>
326 # else
327 # include <mach.h>
328 # endif
329 # endif
330
331 # ifdef sgi
332 # include <sys/sysmp.h>
333 # endif
334
335 # ifdef UMAX
336 # include <signal.h>
337 # include <sys/time.h>
338 # include <sys/wait.h>
339 # include <sys/syscall.h>
340
341 # ifdef UMAX_43
342 # include <machine/cpu.h>
343 # include <inq_stats/statistics.h>
344 # include <inq_stats/sysstats.h>
345 # include <inq_stats/cpustats.h>
346 # include <inq_stats/procstats.h>
347 # else
348 # include <sys/sysdefs.h>
349 # include <sys/statistics.h>
350 # include <sys/sysstats.h>
351 # include <sys/cpudefs.h>
352 # include <sys/cpustats.h>
353 # include <sys/procstats.h>
354 # endif
355 # endif
356
357 # ifdef DGUX
358 # include <sys/dg_sys_info.h>
359 # endif
360
361 # if (defined __linux__ || defined __ANDROID__ \
362 || defined __CYGWIN__ || defined SUNOS_5 \
363 || (defined LOAD_AVE_TYPE && ! defined __VMS))
364 # include <fcntl.h>
365 # endif
366
367
368
369 # ifdef NeXT
370 static processor_set_t default_set;
371 static bool getloadavg_initialized;
372 # endif
373
374 # ifdef UMAX
375 static unsigned int cpus = 0;
376 static unsigned int samples;
377 # endif
378
379 # ifdef DGUX
380 static struct dg_sys_info_load_info load_info;
381 # endif
382
383 # if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
384
385 static int channel;
386
387 static bool getloadavg_initialized;
388
389 static long offset;
390
391 # if ! defined __VMS && ! defined sgi && ! (defined __linux__ || defined __ANDROID__)
392 static struct nlist name_list[2];
393 # endif
394
395 # ifdef SUNOS_5
396 static kvm_t *kd;
397 # endif
398
399 # endif
400
401
402
403
404
405
406 int
407 getloadavg (double loadavg[], int nelem)
408 {
409 int elem = 0;
410
411 # ifdef NO_GET_LOAD_AVG
412 # define LDAV_DONE
413 errno = ENOSYS;
414 elem = -1;
415 # endif
416
417 # if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT)
418
419 # define LDAV_DONE
420 kstat_ctl_t *kc;
421 kstat_t *ksp;
422 kstat_named_t *kn;
423 int saved_errno;
424
425 kc = kstat_open ();
426 if (kc == NULL)
427 return -1;
428 ksp = kstat_lookup (kc, "unix", 0, "system_misc");
429 if (ksp == NULL)
430 return -1;
431 if (kstat_read (kc, ksp, 0) == -1)
432 return -1;
433
434
435 kn = kstat_data_lookup (ksp, "avenrun_1min");
436 if (kn == NULL)
437 {
438
439 nelem = 0;
440 elem = -1;
441 }
442
443 if (nelem >= 1)
444 loadavg[elem++] = (double) kn->value.ul / FSCALE;
445
446 if (nelem >= 2)
447 {
448 kn = kstat_data_lookup (ksp, "avenrun_5min");
449 if (kn != NULL)
450 {
451 loadavg[elem++] = (double) kn->value.ul / FSCALE;
452
453 if (nelem >= 3)
454 {
455 kn = kstat_data_lookup (ksp, "avenrun_15min");
456 if (kn != NULL)
457 loadavg[elem++] = (double) kn->value.ul / FSCALE;
458 }
459 }
460 }
461
462 saved_errno = errno;
463 kstat_close (kc);
464 errno = saved_errno;
465 # endif
466
467 # if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC)
468
469
470 # define LDAV_DONE
471 # undef LOAD_AVE_TYPE
472
473 struct pst_dynamic dyn_info;
474 if (pstat_getdynamic (&dyn_info, sizeof (dyn_info), 0, 0) < 0)
475 return -1;
476 if (nelem > 0)
477 loadavg[elem++] = dyn_info.psd_avg_1_min;
478 if (nelem > 1)
479 loadavg[elem++] = dyn_info.psd_avg_5_min;
480 if (nelem > 2)
481 loadavg[elem++] = dyn_info.psd_avg_15_min;
482
483 # endif
484
485 # if ! defined LDAV_DONE && defined HAVE_LIBPERFSTAT
486 # define LDAV_DONE
487 # undef LOAD_AVE_TYPE
488
489 {
490 perfstat_cpu_total_t cpu_stats;
491 int result = perfstat_cpu_total (NULL, &cpu_stats, sizeof cpu_stats, 1);
492 if (result == -1)
493 return result;
494 loadavg[0] = cpu_stats.loadavg[0] / (double)(1 << SBITS);
495 loadavg[1] = cpu_stats.loadavg[1] / (double)(1 << SBITS);
496 loadavg[2] = cpu_stats.loadavg[2] / (double)(1 << SBITS);
497 elem = 3;
498 }
499 # endif
500
501 # if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__)
502
503 # define LDAV_DONE
504 # undef LOAD_AVE_TYPE
505
506 # ifndef LINUX_LDAV_FILE
507 # define LINUX_LDAV_FILE "/proc/loadavg"
508 # endif
509
510 char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
511 char const *ptr = ldavgbuf;
512 int fd, count, saved_errno;
513
514 fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC);
515 if (fd == -1)
516 return -1;
517 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
518 saved_errno = errno;
519 (void) close (fd);
520 errno = saved_errno;
521 if (count <= 0)
522 return -1;
523 ldavgbuf[count] = '\0';
524
525 for (elem = 0; elem < nelem; elem++)
526 {
527 double numerator = 0;
528 double denominator = 1;
529
530 while (*ptr == ' ')
531 ptr++;
532
533
534
535 if (! ('0' <= *ptr && *ptr <= '9'))
536 {
537 if (elem == 0)
538 {
539 errno = ENOTSUP;
540 return -1;
541 }
542 break;
543 }
544
545 while ('0' <= *ptr && *ptr <= '9')
546 numerator = 10 * numerator + (*ptr++ - '0');
547
548 if (*ptr == '.')
549 for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
550 numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
551
552 loadavg[elem] = numerator / denominator;
553 }
554
555 return elem;
556
557 # endif
558
559 # if !defined (LDAV_DONE) && defined (__NetBSD__)
560 # define LDAV_DONE
561 # undef LOAD_AVE_TYPE
562
563 # ifndef NETBSD_LDAV_FILE
564 # define NETBSD_LDAV_FILE "/kern/loadavg"
565 # endif
566
567 unsigned long int load_ave[3], scale;
568 int count;
569 char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
570 int fd = open (NETBSD_LDAV_FILE, O_RDONLY | O_CLOEXEC);
571 if (fd < 0)
572 return fd;
573 int nread = read (fd, readbuf, sizeof readbuf - 1);
574 int err = errno;
575 close (fd);
576 if (nread < 0)
577 {
578 errno = err;
579 return -1;
580 }
581 readbuf[nread] = '\0';
582 count = sscanf (readbuf, "%lu %lu %lu %lu\n",
583 &load_ave[0], &load_ave[1], &load_ave[2],
584 &scale);
585 if (count != 4)
586 {
587 errno = ENOTSUP;
588 return -1;
589 }
590
591 for (elem = 0; elem < nelem; elem++)
592 loadavg[elem] = (double) load_ave[elem] / (double) scale;
593
594 return elem;
595
596 # endif
597
598 # if !defined (LDAV_DONE) && defined (NeXT)
599 # define LDAV_DONE
600
601
602 host_t host;
603 struct processor_set_basic_info info;
604 unsigned int info_count;
605
606
607
608
609 if (!getloadavg_initialized)
610 {
611 if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS)
612 getloadavg_initialized = true;
613 }
614
615 if (getloadavg_initialized)
616 {
617 info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
618 if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
619 (processor_set_info_t) &info, &info_count)
620 != KERN_SUCCESS)
621 getloadavg_initialized = false;
622 else
623 {
624 if (nelem > 0)
625 loadavg[elem++] = (double) info.load_average / LOAD_SCALE;
626 }
627 }
628
629 if (!getloadavg_initialized)
630 {
631 errno = ENOTSUP;
632 return -1;
633 }
634 # endif
635
636 # if !defined (LDAV_DONE) && defined (UMAX)
637 # define LDAV_DONE
638
639
640
641
642
643 struct proc_summary proc_sum_data;
644 struct stat_descr proc_info;
645 double load;
646 register unsigned int i, j;
647
648 if (cpus == 0)
649 {
650 register unsigned int c, i;
651 struct cpu_config conf;
652 struct stat_descr desc;
653
654 desc.sd_next = 0;
655 desc.sd_subsys = SUBSYS_CPU;
656 desc.sd_type = CPUTYPE_CONFIG;
657 desc.sd_addr = (char *) &conf;
658 desc.sd_size = sizeof conf;
659
660 if (inq_stats (1, &desc))
661 return -1;
662
663 c = 0;
664 for (i = 0; i < conf.config_maxclass; ++i)
665 {
666 struct class_stats stats;
667 memset (&stats, 0, sizeof stats);
668
669 desc.sd_type = CPUTYPE_CLASS;
670 desc.sd_objid = i;
671 desc.sd_addr = (char *) &stats;
672 desc.sd_size = sizeof stats;
673
674 if (inq_stats (1, &desc))
675 return -1;
676
677 c += stats.class_numcpus;
678 }
679 cpus = c;
680 samples = cpus < 2 ? 3 : (2 * cpus / 3);
681 }
682
683 proc_info.sd_next = 0;
684 proc_info.sd_subsys = SUBSYS_PROC;
685 proc_info.sd_type = PROCTYPE_SUMMARY;
686 proc_info.sd_addr = (char *) &proc_sum_data;
687 proc_info.sd_size = sizeof (struct proc_summary);
688 proc_info.sd_sizeused = 0;
689
690 if (inq_stats (1, &proc_info) != 0)
691 return -1;
692
693 load = proc_sum_data.ps_nrunnable;
694 j = 0;
695 for (i = samples - 1; i > 0; --i)
696 {
697 load += proc_sum_data.ps_nrun[j];
698 if (j++ == PS_NRUNSIZE)
699 j = 0;
700 }
701
702 if (nelem > 0)
703 loadavg[elem++] = load / samples / cpus;
704 # endif
705
706 # if !defined (LDAV_DONE) && defined (DGUX)
707 # define LDAV_DONE
708
709
710
711 dg_sys_info ((long int *) &load_info,
712 DG_SYS_INFO_LOAD_INFO_TYPE,
713 DG_SYS_INFO_LOAD_VERSION_0);
714
715 if (nelem > 0)
716 loadavg[elem++] = load_info.one_minute;
717 if (nelem > 1)
718 loadavg[elem++] = load_info.five_minute;
719 if (nelem > 2)
720 loadavg[elem++] = load_info.fifteen_minute;
721 # endif
722
723 # if !defined (LDAV_DONE) && defined (apollo)
724 # define LDAV_DONE
725
726
727
728
729
730
731
732
733
734
735 extern void proc1_$get_loadav ();
736 unsigned long load_ave[3];
737
738 proc1_$get_loadav (load_ave);
739
740 if (nelem > 0)
741 loadavg[elem++] = load_ave[0] / 65536.0;
742 if (nelem > 1)
743 loadavg[elem++] = load_ave[1] / 65536.0;
744 if (nelem > 2)
745 loadavg[elem++] = load_ave[2] / 65536.0;
746 # endif
747
748 # if !defined (LDAV_DONE) && defined (OSF_MIPS)
749 # define LDAV_DONE
750
751 struct tbl_loadavg load_ave;
752 table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
753 loadavg[elem++]
754 = (load_ave.tl_lscale == 0
755 ? load_ave.tl_avenrun.d[0]
756 : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
757 # endif
758
759 # if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32))
760
761 # define LDAV_DONE
762
763
764 for ( ; elem < nelem; elem++)
765 {
766 loadavg[elem] = 0.0;
767 }
768 # endif
769
770 # if !defined (LDAV_DONE) && defined (OSF_ALPHA)
771 # define LDAV_DONE
772
773 struct tbl_loadavg load_ave;
774 table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
775 for (elem = 0; elem < nelem; elem++)
776 loadavg[elem]
777 = (load_ave.tl_lscale == 0
778 ? load_ave.tl_avenrun.d[elem]
779 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
780 # endif
781
782 # if ! defined LDAV_DONE && defined __VMS
783
784
785 LOAD_AVE_TYPE load_ave[3];
786 static bool getloadavg_initialized;
787 # ifdef eunice
788 struct
789 {
790 int dsc$w_length;
791 char *dsc$a_pointer;
792 } descriptor;
793 # endif
794
795
796 if (!getloadavg_initialized)
797 {
798
799 # ifdef eunice
800 descriptor.dsc$w_length = 18;
801 descriptor.dsc$a_pointer = "$$VMS_LOAD_AVERAGE";
802 # else
803 $DESCRIPTOR (descriptor, "LAV0:");
804 # endif
805 if (sys$assign (&descriptor, &channel, 0, 0) & 1)
806 getloadavg_initialized = true;
807 }
808
809
810 if (getloadavg_initialized
811 && !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0,
812 load_ave, 12, 0, 0, 0, 0) & 1))
813 {
814 sys$dassgn (channel);
815 getloadavg_initialized = false;
816 }
817
818 if (!getloadavg_initialized)
819 {
820 errno = ENOTSUP;
821 return -1;
822 }
823 # endif
824
825 # if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS
826
827
828
829
830 # define LDAV_PRIVILEGED
831
832 LOAD_AVE_TYPE load_ave[3];
833
834
835 if (offset == 0)
836 {
837 # ifndef sgi
838 # if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
839 strcpy (name_list[0].n_name, LDAV_SYMBOL);
840 strcpy (name_list[1].n_name, "");
841 # else
842 # ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
843 name_list[0].n_un.n_name = LDAV_SYMBOL;
844 name_list[1].n_un.n_name = 0;
845 # else
846 name_list[0].n_name = LDAV_SYMBOL;
847 name_list[1].n_name = 0;
848 # endif
849 # endif
850
851 # ifndef SUNOS_5
852 if (
853 # if !defined (_AIX)
854 nlist (KERNEL_FILE, name_list)
855 # else
856 knlist (name_list, 1, sizeof (name_list[0]))
857 # endif
858 >= 0)
859
860 {
861 # ifdef FIXUP_KERNEL_SYMBOL_ADDR
862 FIXUP_KERNEL_SYMBOL_ADDR (name_list);
863 # endif
864 offset = name_list[0].n_value;
865 }
866 # endif
867 # else
868 ptrdiff_t ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
869 if (ldav_off != -1)
870 offset = (long int) ldav_off & 0x7fffffff;
871 # endif
872 }
873
874
875 if (!getloadavg_initialized)
876 {
877 # ifndef SUNOS_5
878 int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
879 if (0 <= fd)
880 {
881 channel = fd;
882 getloadavg_initialized = true;
883 }
884 # else
885
886
887 kd = kvm_open (0, 0, 0, O_RDONLY, 0);
888 if (kd != NULL)
889 {
890
891 kvm_nlist (kd, name_list);
892 offset = name_list[0].n_value;
893 getloadavg_initialized = true;
894 }
895 # endif
896 }
897
898
899 if (offset && getloadavg_initialized)
900 {
901
902 # ifndef SUNOS_5
903 if (lseek (channel, offset, 0) == -1L
904 || read (channel, (char *) load_ave, sizeof (load_ave))
905 != sizeof (load_ave))
906 {
907 close (channel);
908 getloadavg_initialized = false;
909 }
910 # else
911 if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
912 != sizeof (load_ave))
913 {
914 kvm_close (kd);
915 getloadavg_initialized = false;
916 }
917 # endif
918 }
919
920 if (offset == 0 || !getloadavg_initialized)
921 {
922 errno = ENOTSUP;
923 return -1;
924 }
925 # endif
926
927 # if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE)
928 if (nelem > 0)
929 loadavg[elem++] = LDAV_CVT (load_ave[0]);
930 if (nelem > 1)
931 loadavg[elem++] = LDAV_CVT (load_ave[1]);
932 if (nelem > 2)
933 loadavg[elem++] = LDAV_CVT (load_ave[2]);
934
935 # define LDAV_DONE
936 # endif
937
938 # if !defined LDAV_DONE
939 errno = ENOSYS;
940 elem = -1;
941 # endif
942 return elem;
943 }