aboutsummaryrefslogtreecommitdiffstats
path: root/lib/profile/InstrProfilingUtil.c
blob: e146dfca83c864b246b23b8565ce063bc3f73964 (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
/*===- InstrProfilingUtil.c - Support library for PGO instrumentation -----===*\
|*
|*                     The LLVM Compiler Infrastructure
|*
|* This file is distributed under the University of Illinois Open Source
|* License. See LICENSE.TXT for details.
|*
\*===----------------------------------------------------------------------===*/

#include "InstrProfilingUtil.h"

#ifdef _WIN32
#include <direct.h>
#elif I386_FREEBSD
int mkdir(const char*, unsigned short);
#else
#include <sys/stat.h>
#include <sys/types.h>
#endif

__attribute__((visibility("hidden")))
void __llvm_profile_recursive_mkdir(char *path) {
  int i;

  for (i = 1; path[i] != '\0'; ++i) {
    if (path[i] != '/') continue;
    path[i] = '\0';
#ifdef _WIN32
    _mkdir(path);
#else
    mkdir(path, 0755);  /* Some of these will fail, ignore it. */
#endif
    path[i] = '/';
  }
}