aboutsummaryrefslogtreecommitdiffstats
path: root/erts/doc/src/erl_nif.xml
blob: 0dd46a951a87ea9e70a6ca2d05b0b1ac64ec7a94 (plain) (blame)
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
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE cref SYSTEM "cref.dtd">

<cref>
  <header>
    <copyright>
      <year>2001</year><year>2009</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.
    
      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.
    
    </legalnotice>

    <title>erl_nif</title>
    <prepared>Sverker Eriksson</prepared>
    <responsible>Sverker Eriksson</responsible>
    <docno>1</docno>
    <approved></approved>
    <checked></checked>
    <date>2009-11-17</date>
    <rev>PA1</rev>
    <file>erl_nif.xml</file>
  </header>
  <lib>erl_nif</lib>
  <libsummary>API functions for an Erlang NIF library</libsummary>
  <description>
     <warning><p>The NIF concept was introduced in R13B03 as an
	EXPERIMENTAL feature. The interfaces may be changed in any way
	in coming releases. The plan is however to lift the experimental label and
  maintain interface backward compatibility from R14B.</p>
  <p>Incompatible changes in <em>R13B04</em>:</p>
  <list>
    <item>The function prototypes of the NIFs have  changed to expect <c>argc</c> and <c>argv</c>
	  arguments. The arity of a NIF is by that no longer limited to 3.</item>
    <item><c>enif_get_data</c> renamed as <c>enif_priv_data</c>.</item>
    <item><c>enif_make_string</c> got a third argument for character encoding.</item>
  </list>
  </warning>

    <p>A NIF library contains native implementation of some functions
    of an Erlang module. The native implemented functions (NIFs) are
    called like any other functions without any difference to the
    caller. Each NIF must also have an implementation in Erlang that
    will be invoked if the function is called before the NIF library
    has been successfully loaded. A typical such stub implementation
    is to throw an exception. But it can also be used as a fallback
    implementation if the NIF library is not implemented for some
    architecture.</p>     
    <p>A minimal example of a NIF library can look like this:</p>
      <p/>
      <code type="none">
/* niftest.c */
#include "erl_nif.h"

static ERL_NIF_TERM hello(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    return enif_make_string(env, "Hello world!", ERL_NIF_LATIN1);
}

static ErlNifFunc nif_funcs[] =
{
    {"hello", 0, hello}
};

ERL_NIF_INIT(niftest,nif_funcs,NULL,NULL,NULL,NULL)
</code>

    <p>and the Erlang module would have to look something like
    this:</p>
      <p/>
      <code type="none">
-module(niftest).

-export([init/0, hello/0]).

init() ->
      erlang:load_nif("./niftest", 0).

hello() ->
      "NIF library not loaded".
</code>
    <p>and compile and test something like this (on Linux):</p>
      <p/>
      <code type="none">
$> gcc -fPIC -shared -o niftest.so niftest.c -I $ERL_ROOT/usr/include/
$> erl

1> c(niftest).
{ok,niftest}
2> niftest:hello().
"NIF library not loaded"
3> niftest:init().
ok
4> niftest:hello().
"Hello world!"
</code>

     <p>A better solution for a real module is to take advantage of
     the new directive <seealso
     marker="doc/reference_manual:code_loading#on_load">on_load</seealso> to automatically
     load the NIF library when the module is loaded.</p>
     <note><p>A NIF must be exported or used locally by the module (or both).
     An unused local stub function will be optimized away by the compiler
      causing loading of the NIF library to fail.</p>
    </note>
     <p>A loaded NIF library is tied to the Erlang module code version
     that loaded it. If the module is upgraded with a new version, the
     new Erlang code will have to load its own NIF library (or maybe choose not
     to). The new code version can however choose to load the exact
     same NIF library as the old code if it wants to. Sharing the same
     dynamic library will mean that static data defined by the library
     will be shared as well. To avoid unintentionally shared static
     data, each Erlang module code can keep its own private data. This
     private data can be set when the NIF library is loaded and
     then retrieved by calling <seealso marker="#enif_priv_data">enif_priv_data()</seealso>.</p>
    <p>There is no way to explicitly unload a NIF library. A library will be
     automatically unloaded when the module code that it belongs to is purged
     by the code server. A NIF library will also be unloaded if it is replaced
     by another version of the library by a second call to
     <c>erlang:load_nif/2</c> from the same module code.</p> 
  </description>
  <section>
  <title>FUNCTIONALITY</title>
  <p>All functions that a NIF library needs to do with Erlang are
      performed through the NIF API functions. There are functions
      for the following functionality:</p>
    <taglist>
      <tag>Read and write Erlang terms</tag>
      <item><p>Any Erlang terms can be passed to a NIF as function arguments and
      be returned as function return values. The terms are of C-type <c>ERL_NIF_TERM</c>
      and can only be read or written using API functions. Most functions to read
      the content of a term are prefixed <c>enif_get_</c> and usually return
      true (or false) if the term was of the expected type (or not).    
      The functions to write terms are all prefixed <c>enif_make_</c> and usually
      return the created <c>ERL_NIF_TERM</c>. There are also some functions
      to query terms, like <c>enif_is_atom</c>, <c>enif_is_identical</c> and
      <c>enif_compare</c>.</p></item>
      <tag>Binaries</tag>
      <item><p>Terms of type binary are accessed with the help of the struct type
      <seealso marker="#ErlNifBinary">ErlNifBinary</seealso>    
      that contains a pointer (<c>data</c>) to the raw binary data and the length
      (<c>size</c>) of the data in bytes. Both <c>data</c> and <c>size</c> are
      read-only and should only be written using calls to API functions.
      Instances of <c>ErlNifBinary</c> are however always allocated by the user
      (usually as local variables).</p>
      <p>The raw data pointed to by <c>data</c> is only mutable after a call to
      <seealso marker="#enif_alloc_binary">enif_alloc_binary</seealso> or
      <seealso marker="#enif_realloc_binary">enif_realloc_binary</seealso>.
      All other functions that operates on a binary will leave the data as read-only.
      A mutable binary must in the end either be freed with
      <seealso marker="#enif_release_binary">enif_release_binary</seealso>
      or made read-only by transferring it to an Erlang term with
      <seealso marker="#enif_make_binary">enif_make_binary</seealso>.
      But it does not have do happen in the same NIF call. Read-only binaries
      does not have to be released.</p>
      <p>Binaries are sequences of whole bytes. Bitstrings with an arbitrary
      bit length have no support yet.</p>
       </item>
      <tag>Resource objects</tag>
      <item><p>The use of resource objects is a way to return pointers to
      native data structures from a NIF in a safe way. A resource object is
      just a block of memory allocated with
      <seealso marker="#enif_alloc_resource">enif_alloc_resource()</seealso>.
      A handle ("safe pointer") to this memory block can then be returned to Erlang by the use of
      <seealso marker="#enif_make_resource">enif_make_resource()</seealso>.
      The term returned by <c>enif_make_resource</c>
      is totally opaque in nature. It can be stored and passed between processses
      on the same node, but the only real end usage is to pass it back as argument to a NIF.
      The NIF can then do <seealso marker="#enif_get_resource">enif_get_resource()</seealso>
      and get back a pointer to the memory block that is guaranteed to still be
      valid. A resource object will not be deallocated until the last handle term
      has been garbage collected by the VM and the resource has been
      released with <seealso marker="#enif_release_resource">enif_release_resource()</seealso>
      (not necessarily in that order).</p>      
      <p>All resource objects are created as instances of some <em>resource type</em>.
      This makes resources from different modules to be distinguishable. 
      A resource type is created by calling
      <seealso marker="#enif_open_resource_type">enif_open_resource_type()</seealso>
      when a library is loaded. Objects of that resource type can then later be allocated
      and <c>enif_get_resource</c> verifies that the resource is of the expected type.
      A resource type can have a user supplied destructor function that is
      automatically called when resources of that type are released (by either
      the garbage collector or <c>enif_release_resource</c>). Resource types
      are uniquely identified by a supplied name string.</p>
      <p>Resource types support upgrade in runtime by allowing a loaded NIF
      library to takeover an already existing resource type and thereby
      "inherit" all existing objects of that type. The destructor of the new
      library will thereafter be called for the inherited objects and the
      library with the old destructor function can be safely unloaded. Existing
      resource objects, of a module that is upgraded, must either be deleted
      or taken over by the new NIF library. The unloading of a library will be
      postponed as long as it exists resource objects with a destructor
      function in the library.
      </p>
      <p>Here is a template example of how to create and return a resource object.</p>
      <p/>
      <code type="none">
    ERL_NIF_TERM term;
    MyStruct* ptr = enif_alloc_resource(env, my_resource_type, sizeof(MyStruct));

    /* initialize struct ... */

    term = enif_make_resource(env, ptr);

    if (keep_a_reference_of_our_own) {
        /* store 'ptr' in static variable, private data or other resource object */
    }
    else {
        enif_release_resource(env, obj);
        /* resource now only owned by "Erlang" */
    }
    return term;
}
</code>

      </item>
      <tag>Threads and concurrency</tag>
      <item><p>A NIF is thread-safe without any explicit synchronization as
      long as it acts as a pure function and only reads the supplied
      arguments. As soon as you write towards a shared state either through
      static variables or <seealso marker="#enif_priv_data">enif_priv_data</seealso>
      you need to supply your own explicit synchronization. Resource objects
      will also require synchronization if you treat them as mutable.</p>
      <p>The library initialization callbacks <c>load</c>, <c>reload</c> and
      <c>upgrade</c> are all thread-safe even for shared state data.</p>
      <p>Avoid doing lengthy work in NIF calls as that may degrade the
      responsiveness of the VM. NIFs are called directly by the same scheduler
      thread that executed the calling Erlang code. The calling scheduler will thus
      be blocked from doing any other work until the NIF returns.</p>
      </item>
    </taglist>
  </section>
  <section>
    <title>INITIALIZATION</title>
    <taglist>
      <tag><marker id="ERL_NIF_INIT"/>ERL_NIF_INIT(MODULE, ErlNifFunc funcs[], load, reload, upgrade, unload)</tag>
      <item><p>This is the magic macro to initialize a NIF library. It
      should be evaluated in global file scope.</p>
      <p><c>MODULE</c> is the name of the Erlang module as an
      identifier without string quotations. It will be stringified by
      the macro.</p>
      <p><c>funcs</c> is a static array of function descriptors for
      all the implemented NIFs in this library.</p>
      <p><c>load</c>, <c>reload</c>, <c>upgrade</c> and <c>unload</c>
      are pointers to functions. One of <c>load</c>, <c>reload</c> or
      <c>upgrade</c> will be called to initialize the library.
      <c>unload</c> is called to release the library. They are all
      described individually below.</p>
      </item>

      <tag><marker id="load"/>int (*load)(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)</tag>
       <item><p><c>load</c> is called when the NIF library is loaded
        and there is no previously loaded library for this module.</p>
        <p><c>*priv_data</c> can be set to point to some private data
           that the library needs in able to keep a state between NIF 
           calls. <c>enif_priv_data()</c> will return this pointer.
           <c>*priv_data</c> will be initialized to NULL when <c>load</c> is
           called.</p> 
        <p><c>load_info</c> is the second argument to <seealso
           marker="erlang#load_nif-2">erlang:load_nif/2</seealso>.</p>
        <p>The library will fail to load if <c>load</c> returns
           anything other than 0. <c>load</c> can be NULL in case no
           initialization is needed.</p> 
       </item>

      <tag><marker id="reload"/>int (*reload)(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)</tag>
       <item><p><c>reload</c> is called when the NIF library is loaded
        and there is already a previously loaded library for this
        module code.</p>
        <p>Works the same as <c>load</c>. The only difference is that
        <c>*priv_data</c> already contains the value set by the
        previous call to <c>load</c> or <c>reload</c>.</p>
        <p>The library will fail to load if <c>reload</c> returns
           anything other than 0 or if <c>reload</c> is NULL.</p> 
      </item>

      <tag><marker id="upgrade"/>int (*upgrade)(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info)</tag>
       <item><p><c>upgrade</c> is called when the NIF library is loaded
        and there is no previously loaded library for this module
        code, BUT there is old code of this module with a loaded NIF library.</p>
        <p>Works the same as <c>load</c>. The only difference is that
        <c>*old_priv_data</c> already contains the value set by the
         last call to <c>load</c> or <c>reload</c> for the old module
         code. <c>*priv_data</c> will be initialized to NULL when <c>upgrade</c>
         is called. It is allowed to write to both *priv_data and *old_priv_data.</p> 
        <p>The library will fail to load if <c>upgrade</c> returns
           anything other than 0 or if <c>upgrade</c> is NULL.</p>
      </item>

      <tag><marker id="unload"/>void (*unload)(ErlNifEnv* env, void* priv_data)</tag>
       <item><p><c>unload</c> is called when the module code that
       the NIF library belongs to is purged as old. New code
       of the same module may or may not exist. Note that <c>unload</c> is not
       called for a replaced library as a consequence of <c>reload</c>.</p>
      </item>

    </taglist>
  </section>

  <section>
    <title>DATA TYPES</title>

    <taglist>
      <tag><marker id="ERL_NIF_TERM"/>ERL_NIF_TERM</tag>
       <item>
        <p>Variables of type <c>ERL_NIF_TERM</c> can refer to any Erlang term.
        This is an opaque type and values of it can only by used either as
        arguments to API functions or as return values from NIFs. A variable of
        type <c>ERL_NIF_TERM</c> is only valid until the NIF call, where it was
        obtained, returns.</p>
      </item>
     <tag><marker id="ErlNifEnv"/>ErlNifEnv</tag>
      <item>
        <p><c>ErlNifEnv</c> contains information about the context in
          which a NIF call is made. This pointer should not be
          dereferenced in any way, but only passed on to API
          functions. An <c>ErlNifEnv</c> pointer is only valid until
          the function, where is what supplied as argument,
          returns. There is thus useless and dangerous to store <c>ErlNifEnv</c>
          pointers in between NIF calls.</p>
      </item>
    <tag><marker id="ErlNifFunc"/>ErlNifFunc</tag>
     <item>
      <p/>
      <code type="none">
typedef struct {
    const char* <em>name</em>;
    unsigned <em>arity</em>;
    ERL_NIF_TERM (*<em>fptr</em>)(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
} ErlNifFunc;
</code>
        <p>Describes a NIF by its name, arity and implementation.
        <c>fptr</c> is a pointer to the function that implements the
        NIF. The argument <c>argv</c> of a NIF will contain the
        function arguments passed to the NIF and <c>argc</c> is the
        length of the array, i.e. the function arity. <c>argv[N-1]</c>
        will thus denote the Nth argument to the NIF. Note that the
        <c>argc</c> argument allows for the same C function to
        implement several Erlang functions with different arity (but
        same name probably).</p>
      </item>
    <tag><marker id="ErlNifBinary"/>ErlNifBinary</tag>
     <item>
      <p/>
      <code type="none">
typedef struct {
    unsigned <em>size</em>;
    unsigned char* <em>data</em>;
} ErlNifBinary;
</code>
        <p><c>ErlNifBinary</c> contains transient information about an
          inspected binary term. <c>data</c> is a pointer to a buffer
          of <c>size</c> bytes with the raw content of the binary.</p>
      </item>
      <tag><marker id="ErlNifResourceType"/>ErlNifResourceType</tag>
       <item>
          <p>Each instance of <c>ErlNifResourceType</c> represent a class of
          memory managed resource objects that can be garbage collected.
          Each resource type has a unique name and a destructor function that
          is called when objects of its type are released.</p>
        </item>
        <tag><marker id="ErlNifResourceDtor"/>ErlNifResourceDtor</tag>
         <item>
           <p/>
           <code type="none">
typedef void ErlNifResourceDtor(ErlNifEnv* env, void* obj);
</code>
            <p>The function prototype of a resource destructor function.
            A destructor function is not allowed to call any term-making functions.</p>
          </item>
          <tag><marker id="ErlNifCharEncoding"/>ErlNifCharEncoding</tag>
           <item>
             <p/>
             <code type="none">
typedef enum {
    ERL_NIF_LATIN1
}ErlNifCharEncoding;
</code>
              <p>The character encoding used in strings. The only supported
              encoding is currently <c>ERL_NIF_LATIN1</c> for iso-latin-1
              (8-bit ascii).</p>
            </item>
            <tag><marker id="ErlNifSysInfo"/>ErlNifSysInfo</tag>
             <item>
                <p>Used by <seealso marker="#enif_system_info">enif_system_info</seealso>
                to return information about the runtime system. Contains currently
                the exact same content as <seealso marker="erl_driver#ErlDrvSysInfo">ErlDrvSysInfo</seealso>.</p>
              </item>

    </taglist>
  </section>

  <funcs>
    <func><name><ret>void*</ret><nametext>enif_alloc(ErlNifEnv* env, size_t size)</nametext></name>
      <fsummary>Allocate dynamic memory.</fsummary>
      <desc><p>Allocate memory of <c>size</c> bytes. Return NULL if allocation failed.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_alloc_binary(ErlNifEnv* env, unsigned size, ErlNifBinary* bin)</nametext></name>
      <fsummary>Create a new binary.</fsummary>
      <desc><p>Allocate a new binary of size of <c>size</c>
      bytes. Initialize the structure pointed to by <c>bin</c> to
      refer to the allocated binary. The binary must either be released by 
      <seealso marker="#enif_release_binary">enif_release_binary()</seealso> 
      or ownership transferred to an Erlang term with 
      <seealso marker="#enif_make_binary">enif_make_binary()</seealso>. 
      An allocated (and owned) <c>ErlNifBinary</c> can be kept between NIF
      calls.</p>
        <p>Return false if allocation failed.</p>
      </desc>
    </func>
    <func><name><ret>void*</ret><nametext>enif_alloc_resource(ErlNifEnv* env, ErlNifResourceType* type, unsigned size)</nametext></name>
      <fsummary>Allocate a memory managed resource object</fsummary>
      <desc><p>Allocate a memory managed resource object of type <c>type</c> and size <c>size</c> bytes.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_compare(ErlNifEnv* env, ERL_NIF_TERM lhs, ERL_NIF_TERM rhs)</nametext></name>
      <fsummary>Compare two terms</fsummary>
      <desc><p>Return an integer less than, equal to, or greater than
      zero if <c>lhs</c> is found, respectively, to be less than,
      equal, or greater than <c>rhs</c>. Corresponds to the Erlang
      operators <c>==</c>, <c>/=</c>, <c>=&lt;</c>, <c>&lt;</c>,
      <c>&gt;=</c> and <c>&gt;</c> (but <em>not</em> <c>=:=</c> or <c>=/=</c>).</p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_cond_broadcast(ErlNifCond *cnd)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_cond_broadcast">erl_drv_cond_broadcast()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>ErlNifCond*</ret><nametext>enif_cond_create(char *name)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_cond_create">erl_drv_cond_create()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_cond_destroy(ErlNifCond *cnd)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_cond_destroy">erl_drv_cond_destroy()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_cond_signal(ErlNifCond *cnd)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_cond_signal">erl_drv_cond_signal()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_cond_wait(ErlNifCond *cnd, ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_cond_wait">erl_drv_cond_wait()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_equal_tids(ErlNifTid tid1, ErlNifTid tid2)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_equal_tids">erl_drv_equal_tids()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_free(ErlNifEnv* env, void* ptr)</nametext></name>
      <fsummary>Free dynamic memory</fsummary>
      <desc><p>Free memory allocated by <c>enif_alloc</c>.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_atom(ErlNifEnv* env, 
                  ERL_NIF_TERM term, char* buf, unsigned size)
                             </nametext></name>
      <fsummary>Get the text representation of an atom term</fsummary>
      <desc><p>Write a null-terminated string, in the buffer pointed to by
              <c>buf</c> of size <c>size</c>, consisting of the string 
              representation of the atom <c>term</c>. Return the number of bytes
              written (including terminating null character) or 0 if
              <c>term</c> is not an atom with maximum length of 
              <c>size-1</c>.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_double(ErlNifEnv* env, ERL_NIF_TERM term, double* dp)</nametext></name>
      <fsummary>Read a floating-point number term.</fsummary>
      <desc><p>Set <c>*dp</c> to the floating point value of
      <c>term</c> or return false if <c>term</c> is not a float.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_int(ErlNifEnv* env, ERL_NIF_TERM term, int* ip)</nametext></name>
      <fsummary>Read an integer term.</fsummary>
      <desc><p>Set <c>*ip</c> to the integer value of
      <c>term</c> or return false if <c>term</c> is not an integer or is
      outside the bounds of type <c>int</c></p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_list_cell(ErlNifEnv* env, ERL_NIF_TERM list, ERL_NIF_TERM* head, ERL_NIF_TERM* tail)</nametext></name>
      <fsummary>Get head and tail from a list</fsummary>
      <desc><p>Set <c>*head</c> and <c>*tail</c> from
      <c>list</c> or return false if <c>list</c> is not a non-empty
      list.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_long(ErlNifEnv* env, ERL_NIF_TERM term, long int* ip)</nametext></name>
      <fsummary>Read an long integer term.</fsummary>
      <desc><p>Set <c>*ip</c> to the long integer value of
      <c>term</c> or return false if <c>term</c> is not an integer or is
      outside the bounds of type <c>long int</c>.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_resource(ErlNifEnv* env, ERL_NIF_TERM term, ErlNifResourceType* type, void** objp)</nametext></name>
      <fsummary>Get the pointer to a resource object</fsummary>
      <desc><p>Set <c>*objp</c> to point to the resource object referred to by <c>term</c>.
      The pointer is valid until the calling NIF returns and should not be released.</p>
      <p>Return false if <c>term</c> is not a handle to a resource object
      of type <c>type</c>.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_string(ErlNifEnv* env, 
                                ERL_NIF_TERM list, char* buf, unsigned size,
                                ErlNifCharEncoding encode)</nametext></name>
      <fsummary>Get a C-string from a list.</fsummary>
      <desc><p>Write a null-terminated string, in the buffer pointed to by
              <c>buf</c> with size <c>size</c>, consisting of the characters
              in the string <c>list</c>. The characters are written using encoding
              <seealso marker="#ErlNifCharEncoding">encode</seealso>.
              Return the number of bytes written (including terminating null
              character), or <c>-size</c> if the string was truncated due to
              buffer space, or 0 if <c>list</c> is not a string that can be
              encoded with <c>encode</c> or if <c>size</c> was less than 1.              
              The written string is always null-terminated unless buffer
              <c>size</c> is less than 1.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_tuple(ErlNifEnv* env, ERL_NIF_TERM term, int* arity, const ERL_NIF_TERM** array)</nametext></name>
      <fsummary>Inspect the elements of a tuple.</fsummary>
      <desc><p>If <c>term</c> is a tuple, set <c>*array</c> to point
      to an array containing the elements of the tuple and set
      <c>*arity</c> to the number of elements. Note that the array
      is read-only and <c>(*array)[N-1]</c> will be the Nth element of
      the tuple. <c>*array</c> is undefined if the arity of the tuple
      is zero.</p><p>Return false if <c>term</c> is not a
      tuple.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_get_uint(ErlNifEnv* env, ERL_NIF_TERM term, unsigned int* ip)</nametext></name>
      <fsummary>Read an unsigned integer term.</fsummary>
      <desc><p>Set <c>*ip</c> to the unsigned integer value of
      <c>term</c> or return false if <c>term</c> is not an unsigned integer or is
      outside the bounds of type <c>unsigned int</c></p></desc>
    </func>

    <func><name><ret>int</ret><nametext>enif_get_ulong(ErlNifEnv* env, ERL_NIF_TERM term, unsigned long* ip)</nametext></name>
      <fsummary>Read an unsigned integer term.</fsummary>
      <desc><p>Set <c>*ip</c> to the unsigned long integer value of
      <c>term</c> or return false if <c>term</c> is not an unsigned integer or is
      outside the bounds of type <c>unsigned long</c></p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_inspect_binary(ErlNifEnv* env, ERL_NIF_TERM bin_term, ErlNifBinary* bin)</nametext></name>
      <fsummary>Inspect the content of a binary</fsummary>
      <desc><p>Initialize the structure pointed to by <c>bin</c> with 
              information about the binary term
      <c>bin_term</c>. Return false if <c>bin_term</c> is not a binary.</p></desc> 
    </func>
    <func><name><ret>int</ret><nametext>enif_inspect_iolist_as_binary(ErlNifEnv* 
                                env, ERL_NIF_TERM term, ErlNifBinary* bin)
                              </nametext></name>
      <fsummary>Inspect the content of an iolist</fsummary>
      <desc><p>Initialize the structure pointed to by <c>bin</c> with one
      continuous buffer with the same byte content as <c>iolist</c>. As with 
      inspect_binary, the data pointed to by <c>bin</c> is transient and does 
      not need to be released. Return false if <c>iolist</c> is not an
      iolist.</p>
      </desc> 
    </func>
    <func><name><ret>int</ret><nametext>enif_is_atom(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is an atom</fsummary>
      <desc><p>Return true if <c>term</c> is an atom.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_binary(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a binary</fsummary>
      <desc><p>Return true if <c>term</c> is a binary</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_empty_list(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is an empty list</fsummary>
      <desc><p>Return true if <c>term</c> is an empty list.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_fun(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a fun</fsummary>
      <desc><p>Return true if <c>term</c> is a fun.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_identical(ErlNifEnv* env, ERL_NIF_TERM lhs, ERL_NIF_TERM rhs)</nametext></name>
      <fsummary>Erlang operator =:=</fsummary>
      <desc><p>Return true if the two terms are identical. Corresponds to the
      Erlang operators <c>=:=</c> and
      <c>=/=</c>.</p></desc> 
    </func>
    <func><name><ret>int</ret><nametext>enif_is_pid(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a pid</fsummary>
      <desc><p>Return true if <c>term</c> is a pid.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_is_port(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a port</fsummary>
      <desc><p>Return true if <c>term</c> is a port.</p></desc>
    </func>

    <func><name><ret>int</ret><nametext>enif_is_ref(ErlNifEnv* env, ERL_NIF_TERM term)</nametext></name>
      <fsummary>Determine if a term is a reference</fsummary>
      <desc><p>Return true if <c>term</c> is a reference.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_atom(ErlNifEnv* env, const char* name)</nametext></name>
      <fsummary>Create an atom term</fsummary>
      <desc><p>Create an atom term from the C-string <c>name</c>. Unlike other terms, atom
      terms may be saved and used between NIF calls.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_badarg(ErlNifEnv* env)</nametext></name>
      <fsummary>Make a badarg exception.</fsummary>
      <desc><p>Make a badarg exception to be returned from a NIF.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_binary(ErlNifEnv* env, ErlNifBinary* bin)</nametext></name>
      <fsummary>Make a binary term.</fsummary>
      <desc><p>Make a binary term from <c>bin</c>. Any ownership of 
              the binary data will be transferred to the created term and
              <c>bin</c> should be considered read-only for the rest of the NIF
              call and then as released.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_double(ErlNifEnv* env, double d)</nametext></name>
      <fsummary>Create an floating-point term</fsummary>
      <desc><p>Create an floating-point term from a <c>double</c>.</p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_make_existing_atom(ErlNifEnv* env, const char* name, ERL_NIF_TERM* atom)</nametext></name>
      <fsummary>Create an existing atom term</fsummary>
      <desc><p>Try to create the term of an already existing atom from
      the C-string <c>name</c>. If the atom already exist store the
      term in <c>*atom</c> and return true, otherwise return
      false.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_int(ErlNifEnv* env, int i)</nametext></name>
      <fsummary>Create an integer term</fsummary>
      <desc><p>Create an integer term.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list(ErlNifEnv* env, unsigned cnt, ...)</nametext></name>
      <fsummary>Create a list term.</fsummary>
      <desc><p>Create an ordinary list term of length <c>cnt</c>. Expects
      <c>cnt</c> number of arguments (after <c>cnt</c>) of type ERL_NIF_TERM as the
      elements of the list. An empty list is returned if <c>cnt</c> is 0.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list1(ErlNifEnv* env, ERL_NIF_TERM e1)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list2(ErlNifEnv* env, ERL_NIF_TERM e1, ERL_NIF_TERM e2)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list3(ErlNifEnv* env, ERL_NIF_TERM e1, ERL_NIF_TERM e2, ERL_NIF_TERM e3)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list4(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e4)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list5(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e5)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list6(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e6)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list7(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e7)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list8(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e8)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list9(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e9)</nametext></name>
      <fsummary>Create a list term.</fsummary>
      <desc><p>Create an ordinary list term with length indicated by the
      function name. Prefer these functions (macros) over the variadic
      <c>enif_make_list</c>  to get compile time error if the number of
      arguments does not match.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list_cell(ErlNifEnv* env, ERL_NIF_TERM head, ERL_NIF_TERM tail)</nametext></name>
      <fsummary>Create a list cell.</fsummary>
      <desc><p>Create a list cell <c>[head | tail]</c>.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_list_from_array(ErlNifEnv* env, const ERL_NIF_TERM arr[], unsigned cnt)</nametext></name>
      <fsummary>Create a list term from an array.</fsummary>
      <desc><p>Create an ordinary list containing the elements of array <c>arr</c>
      of length <c>cnt</c>. An empty list is returned if <c>cnt</c> is 0.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_long(ErlNifEnv* env, long int i)</nametext></name>
      <fsummary>Create an integer term from a long int</fsummary>
      <desc><p>Create an integer term from a <c>long int</c>.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_ref(ErlNifEnv* env)</nametext></name>
      <fsummary>Create a reference.</fsummary>
      <desc><p>Create a reference like <seealso marker="erlang#make_ref-0">erlang:make_ref/0</seealso>.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_resource(ErlNifEnv* env, void* obj)</nametext></name>
      <fsummary>Create an opaque handle to a resource object</fsummary>
      <desc><p>Create an opaque handle to a memory managed resource object
      obtained by <seealso marker="#enif_alloc_resource">enif_alloc_resource</seealso>.
      No ownership transfer is done, the resource object still needs to be released by
      <seealso marker="#enif_release_resource">enif_release_resource</seealso>.</p>
      <p>Note that the only defined behaviour when using of a resource term in
      an Erlang program is to store it and send it between processes on the
      same node. Other operations such as matching or <c>term_to_binary</c>
      will have unpredictable (but harmless) results.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_string(ErlNifEnv* env, const char* string, ErlNifCharEncoding encoding)</nametext></name>
      <fsummary>Create a string.</fsummary>
      <desc><p>Create a list containing the characters of the
      null-terminated string <c>string</c> with encoding <seealso marker="#ErlNifCharEncoding">encoding</seealso>.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_sub_binary(ErlNifEnv* 
      env, ERL_NIF_TERM bin_term, unsigned pos, unsigned size)</nametext></name>
      <fsummary>Make a subbinary term.</fsummary>
      <desc><p>Make a subbinary of binary <c>bin_term</c>, starting at 
              zero-based position <c>pos</c> with a length of <c>size</c> bytes. 
              <c>bin_term</c> must be a binary or bitstring and
              <c>pos+size</c> must be less or equal to the number of whole
              bytes in <c>bin_term</c>.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple(ErlNifEnv* env, unsigned cnt, ...)</nametext></name>
      <fsummary>Create a tuple term.</fsummary>
      <desc><p>Create a tuple term of arity <c>cnt</c>. Expects
      <c>cnt</c> number of arguments (after <c>cnt</c>) of type ERL_NIF_TERM as the
      elements of the tuple.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple1(ErlNifEnv* env, ERL_NIF_TERM e1)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple2(ErlNifEnv* env, ERL_NIF_TERM e1, ERL_NIF_TERM e2)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple3(ErlNifEnv* env, ERL_NIF_TERM e1, ERL_NIF_TERM e2, ERL_NIF_TERM e3)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple4(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e4)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple5(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e5)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple6(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e6)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple7(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e7)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple8(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e8)</nametext></name>
    <name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple9(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e9)</nametext></name>
      <fsummary>Create a tuple term.</fsummary>
      <desc><p>Create a tuple term with length indicated by the
      function name. Prefer these functions (macros) over the variadic
      <c>enif_make_tuple</c>  to get compile time error if the number of
      arguments does not match.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_tuple_from_array(ErlNifEnv* env, const ERL_NIF_TERM arr[], unsigned cnt)</nametext></name>
      <fsummary>Create a tuple term from an array.</fsummary>
      <desc><p>Create a tuple containing the elements of array <c>arr</c>
      of length <c>cnt</c>.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_uint(ErlNifEnv* env, unsigned int i)</nametext></name>
      <fsummary>Create an unsigned integer term</fsummary>
      <desc><p>Create an integer term from an <c>unsigned int</c>.</p></desc>
    </func>
    <func><name><ret>ERL_NIF_TERM</ret><nametext>enif_make_ulong(ErlNifEnv* env, unsigned long i)</nametext></name>
      <fsummary>Create an integer term from an unsigned long int</fsummary>
      <desc><p>Create an integer term from an <c>unsigned long int</c>.</p></desc>
    </func>
    <func><name><ret>ErlNifMutex*</ret><nametext>enif_mutex_create(char *name)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_mutex_create">erl_drv_mutex_create()</seealso>.
    </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_mutex_destroy(ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_mutex_destroy">erl_drv_mutex_destroy()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_mutex_lock(ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_mutex_lock">erl_drv_mutex_lock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_mutex_trylock(ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_mutex_trylock">erl_drv_mutex_trylock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_mutex_unlock(ErlNifMutex *mtx)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_mutex_unlock">erl_drv_mutex_unlock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>ErlNifResourceType*</ret><nametext>enif_open_resource_type(ErlNifEnv* env, const char* name,
                             ErlNifResourceDtor* dtor, ErlNifResourceFlags flags, ErlNifResourceFlags* tried)</nametext></name>
      <fsummary>Create or takeover a resource type</fsummary>
      <desc><p>Create or takeover a resource type identified by the string
      <c>name</c> and give it the destructor function pointed to by <seealso marker="#ErlNifResourceDtor">dtor</seealso>.
      Argument <c>flags</c> can have the following values:</p>
      <taglist>
        <tag><c>ERL_NIF_RT_CREATE</c></tag>
              <item>Create a new resource type that does not already exist.</item>
        <tag><c>ERL_NIF_RT_TAKEOVER</c></tag>
              <item>Open an existing resource type and take over ownership of all its instances.
               The supplied destructor <c>dtor</c> will be called both for existing instances
               as well as new instances not yet created by the calling NIF library.</item>            
      </taglist>
      <p>The two flag values can be combined with bitwise-or. To avoid unintentionally
      name clashes a good practice is to include the module name as part of the
      type <c>name</c>. The <c>dtor</c> may  be <c>NULL</c> in case no destructor
      is needed.</p>
      <p>On success, return a pointer to the resource type and <c>*tried</c>
      will be set to either <c>ERL_NIF_RT_CREATE</c> or
      <c>ERL_NIF_RT_TAKEOVER</c> to indicate what was actually done.
       On failure, return <c>NULL</c> and set <c>*tried</c> to <c>flags</c>.
       It is allowed to set <c>tried</c> to <c>NULL</c>.</p>
       <p>Note that <c>enif_open_resource_type</c> is only allowed to be called in the three callbacks
       <seealso marker="#load">load</seealso>, <seealso marker="#reload">reload</seealso>
       and <seealso marker="#upgrade">upgrade</seealso>.</p>
      </desc>
    </func>
    <func><name><ret>void*</ret><nametext>enif_priv_data(ErlNifEnv* env)</nametext></name>
      <fsummary>Get the private data of a NIF library</fsummary>
      <desc><p>Return the pointer to the private data that was set by <c>load</c>,
      <c>reload</c> or <c>upgrade</c>.</p>
      <p>Was previously named <c>enif_get_data</c>.</p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_realloc_binary(ErlNifEnv* env, ErlNifBinary* bin, unsigned size)</nametext></name>
      <fsummary>Change the size of a binary.</fsummary>
      <desc><p>Change the size of a binary <c>bin</c>. The source binary
      may be read-only, in which case it will be left untouched and
      a mutable copy is allocated and assigned to <c>*bin</c>.</p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_release_binary(ErlNifEnv* env, ErlNifBinary* bin)</nametext></name>
      <fsummary>Release a binary.</fsummary>
      <desc><p>Release a binary obtained 
              from <c>enif_alloc_binary</c>.</p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_release_resource(ErlNifEnv* env, void* obj)</nametext></name>
      <fsummary>Release a resource object.</fsummary>
      <desc><p>Release a resource objects obtained from <c>enif_alloc_resource</c>.
      The object may still be alive if it is referred to by Erlang terms. Each call to
      <c>enif_release_resource</c> must correspond to a previous call to <c>enif_alloc_resource</c>.
      References made by <c>enif_make_resource</c> can only be released by the garbage collector.</p></desc>
    </func>
    <func><name><ret>ErlNifRWLock*</ret><nametext>enif_rwlock_create(char *name)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_rwlock_create">erl_drv_rwlock_create()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_destroy(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_rwlock_destroy">erl_drv_rwlock_destroy()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_rlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_rwlock_rlock">erl_drv_rwlock_rlock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_runlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_rwlock_runlock">erl_drv_rwlock_runlock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_rwlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_rwlock_rwlock">erl_drv_rwlock_rwlock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_rwlock_rwunlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_rwlock_rwunlock">erl_drv_rwlock_rwunlock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_rwlock_tryrlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_rwlock_tryrlock">erl_drv_rwlock_tryrlock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_rwlock_tryrwlock(ErlNifRWLock *rwlck)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_rwlock_tryrwlock">erl_drv_rwlock_tryrwlock()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>unsigned</ret><nametext>enif_sizeof_resource(ErlNifEnv* env, void* obj)</nametext></name>
      <fsummary>Get the byte size of a resource object</fsummary>
      <desc><p>Get the byte size of a resource object <c>obj</c> obtained by
      <c>enif_alloc_resource</c>.</p></desc>
    </func>
    <func>
      <name><ret>void</ret><nametext>enif_system_info(ErlNifSysInfo *sys_info_ptr, size_t size)</nametext></name>
      <fsummary>Get information about the Erlang runtime system</fsummary>
      <desc><p>Same as <seealso marker="erl_driver#driver_system_info">driver_system_info()</seealso>.
            </p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_thread_create(char *name,ErlNifTid *tid,void * (*func)(void *),void *args,ErlNifThreadOpts *opts)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_thread_create">erl_drv_thread_create()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_thread_exit(void *resp)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_thread_exit">erl_drv_thread_exit()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_thread_join(ErlNifTid, void **respp)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_thread_join">erl_drv_thread_join ()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>ErlNifThreadOpts*</ret><nametext>enif_thread_opts_create(char *name)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_thread_opts_create">erl_drv_thread_opts_create()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_thread_opts_destroy(ErlNifThreadOpts *opts)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_thread_opts_destroy">erl_drv_thread_opts_destroy()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>ErlNifTid</ret><nametext>enif_thread_self(void)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_thread_self">erl_drv_thread_self()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>int</ret><nametext>enif_tsd_key_create(char *name, ErlNifTSDKey *key)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_tsd_key_create">erl_drv_tsd_key_create()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_tsd_key_destroy(ErlNifTSDKey key)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_tsd_key_destroy">erl_drv_tsd_key_destroy()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void*</ret><nametext>enif_tsd_get(ErlNifTSDKey key)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_tsd_get">erl_drv_tsd_get()</seealso>.
          </p></desc>
    </func>
    <func><name><ret>void</ret><nametext>enif_tsd_set(ErlNifTSDKey key, void *data)</nametext></name>
    <fsummary></fsummary>
    <desc><p>Same as <seealso marker="erl_driver#erl_drv_tsd_set">erl_drv_tsd_set()</seealso>.
          </p></desc>
    </func>
  </funcs>
  <section>
    <title>SEE ALSO</title>
    <p><seealso marker="erlang#load_nif-2">load_nif(3)</seealso></p>
  </section>
</cref>