Engee documentation

The C Standard Library

malloc(size::Integer) -> Ptr{Cvoid}

Calls malloc from the C standard library.

calloc(num::Integer, size::Integer) -> Ptr{Cvoid}

Calls calloc from the C standard library.

realloc(addr::Ptr, size::Integer) -> Ptr{Cvoid}

Calls 'realloc` from the C standard library.

See the warning in the documentation for free that this feature can only be used for the memory originally received from malloc.

memcpy(dst::Ptr, src::Ptr, n::Integer) -> Ptr{Cvoid}

Calls `memcpy' from the C standard library.

Compatibility: Julia 1.10

To support memcpy` a version of Julia at least 1.10 is required.

memmove(dst::Ptr, src::Ptr, n::Integer) -> Ptr{Cvoid}

Calls `memmove' from the C standard library.

Compatibility: Julia 1.10

To support memmove` a version of Julia at least 1.10 is required.

memset(dst::Ptr, val, n::Integer) -> Ptr{Cvoid}

Calls memset from the C standard library.

Compatibility: Julia 1.10

Julia version 1.10 or higher is required to support memset.

memcmp(a::Ptr, b::Ptr, n::Integer) -> Int

Calls memcmp from the C standard library.

Compatibility: Julia 1.10

To support memcmp` a Julia version of at least 1.9 is required.

free(addr::Ptr)

Calls free from the C standard library. This feature can only be used for memory received from malloc, but not for pointers obtained from other libraries with. Objects 'Ptr` received from C libraries should be released by the appropriate functions defined in these libraries to prevent approval failures in cases where there are multiple libc libraries in the system.

errno([code])

Gets the value from the errno library with. If an argument is specified, it is used to specify the value of `errno'.

The value of errno' is valid only immediately after calling `ccall the C library routine that sets it. In particular, you cannot call `errno' on the next command line in the REPL, because most of the code is executed between command lines.

strerror(n=errno())

Converts the system call error code into a string with a description.

GetLastError()

Calls the Win32 function `GetLastError' (available only on Windows).

FormatMessage(n=GetLastError())

Converts the error code of the Win32 system call into a string with a description (available only in Windows).

time(t::TmStruct) -> Float64

Converts the `TmStruct' structure to a time value (in seconds) from the beginning of the countdown.

strftime([format], time)

Converts the time value specified in seconds from the start of the countdown or TmStruct to a formatted string using the specified format. The same formats are supported as in the C standard library.

strptime([format], timestr)

Analyzes the formatted string of the time value in 'TmStruct', giving seconds, minutes, hours, date, etc. The same formats are supported as in the C standard library. Time zones are not analyzed correctly on some platforms. If the result of this function is passed to time to be converted to a time value (in seconds) from the start of the countdown, the isdst field must be filled in manually. The set value -1 tells the C library that it is necessary to use the current system settings to determine the time zone.

TmStruct([seconds])

Converts the time in seconds from the start of the countdown to a broken format (with the fields sec, min, hour, mday, month, year, wday, yday and `isdst').

FILE(::Ptr)
FILE(::IO)

A libc FILE* object representing an open file.

It can be passed as an argument to Ptr{FILE} in ccall. In addition, it supports seek, position and close.

A FILE can be created from a regular IO object, provided that it is an open file. It should be closed later.

Examples

julia> using Base.Libc

julia> mktemp() do _, io
# write to a temporary file using `puts(char*, FILE*)` from libc
file = FILE(io)
ccall(:fputs, Cint, (Cstring, Ptr{FILE}), "hello world", file)
close(file)
# reading the file again
           seek(io, 0)
           read(io, String)
       end
"hello world"
flush_cstdio()

Clears the C execution streams stdout and stderr (which could have been written from third-party C code).

systemsleep(s::Real)

Pauses execution for s seconds. This function does not output data to the Julia scheduler and thus blocks the Julia execution thread that runs during the idle period.

See also the description sleep.

mkfifo(path::AbstractString, [mode::Integer]) -> path

Creates a special FIFO file (named pipe) in the path'. On success, it returns the `path as it is.

'mkfifo` is supported only on Unix platforms.

Compatibility: Julia 1.11

mkfifo requires a version of Julia not lower than 1.11.