---
name: "hal_export_funct"
section: "3hal"
platform: "linux"
package: "linuxcnc-uspace-dev"
version: "1:2.9.4-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/hal_export_funct"
---

# hal\_export\_funct(3hal)

create a realtime function callable from a thread

## NAME

hal\_export\_funct - create a realtime function callable from a thread

## SYNTAX

typedef void(\*hal\_funct\_t)(void \* *arg*, long *period*)

int hal\_export\_funct(const char \**name*, hal\_funct\_t *funct*, void \**arg*, int *uses\_fp*, int *reentrant*, int *comp\_id*)

## ARGUMENTS

- *name*

  The name of the function.

- *funct*

  The pointer to the function

- *arg*

  The argument to be passed as the first parameter of *funct*

- *uses\_fp*

  Nonzero if the function uses floating-point operations, including assignment of floating point values with "=".

- *reentrant*

  If reentrant is non-zero, the function may be preempted and called again before the first call completes.  Otherwise, it may only be added to one thread.

- *comp\_id*

  A HAL component identifier returned by an earlier call to **hal\_init**.

## DESCRIPTION

**hal\_export\_funct** makes a realtime function provided by a component available to the system.  A subsequent call to **hal\_add\_funct\_to\_thread** can be used to schedule the execution of the function as needed by the system.

When this function is placed on a HAL thread, and HAL threads are started, *funct* is called repeatedly with two arguments: *void \*arg* is the same value that was given to **hal\_export\_funct**, and *long period* is the interval between calls in nanoseconds.

Each call to the function should do a small amount of work and return.

## RETURN VALUE

Returns a HAL status code.

## SEE ALSO

**[hal\_create\_thread(3hal)](/hal_create_thread/3hal.md)**, **[hal\_add\_funct\_to\_thread(3hal)](/hal_add_funct_to_thread/3hal.md)**
