1/*===- InstrProfilingUtil.c - Support library for PGO instrumentation -----===*\
2|*
3|*                     The LLVM Compiler Infrastructure
4|*
5|* This file is distributed under the University of Illinois Open Source
6|* License. See LICENSE.TXT for details.
7|*
8\*===----------------------------------------------------------------------===*/
9
10#include "InstrProfilingUtil.h"
11#include "InstrProfiling.h"
12
13#ifdef _WIN32
14#include <direct.h>
15#elif I386_FREEBSD
16int mkdir(const char*, unsigned short);
17#else
18#include <sys/stat.h>
19#include <sys/types.h>
20#endif
21
22COMPILER_RT_VISIBILITY
23void __llvm_profile_recursive_mkdir(char *path) {
24  int i;
25
26  for (i = 1; path[i] != '\0'; ++i) {
27    if (path[i] != '/') continue;
28    path[i] = '\0';
29#ifdef _WIN32
30    _mkdir(path);
31#else
32    mkdir(path, 0755);  /* Some of these will fail, ignore it. */
33#endif
34    path[i] = '/';
35  }
36}
37