• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2024 Collabora, Ltd.
3  * SPDX-License-Identifier: MIT
4  *
5  * This file contains helpers that are implemented in C so that, among other
6  * things, we avoid pulling in all of libc as bindings only to access a few
7  * functions.
8  */
9 
10 #include <stdio.h>
11 #include <stdlib.h>
12 
13 #include "rust_helpers.h"
14 
compiler_rs_free(void * ptr)15 void compiler_rs_free(void *ptr)
16 {
17    free(ptr);
18 }
19 
compiler_rs_ftell(FILE * f)20 long compiler_rs_ftell(FILE *f)
21 {
22    return ftell(f);
23 }
24 
compiler_rs_fseek(FILE * f,long offset,int whence)25 int compiler_rs_fseek(FILE *f, long offset, int whence)
26 {
27    return fseek(f, offset, whence);
28 }
29 
compiler_rs_fwrite(const void * ptr,size_t size,size_t nmemb,FILE * stream)30 size_t compiler_rs_fwrite(const void *ptr,
31                           size_t size, size_t nmemb,
32                           FILE *stream)
33 {
34    return fwrite(ptr, size, nmemb, stream);
35 }
36