LMMS
Loading...
Searching...
No Matches
juce_posix_SharedCode.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
27{
28 pthread_mutexattr_t atts;
29 pthread_mutexattr_init (&atts);
30 pthread_mutexattr_settype (&atts, PTHREAD_MUTEX_RECURSIVE);
31 #if ! JUCE_ANDROID
32 pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT);
33 #endif
34 pthread_mutex_init (&lock, &atts);
35 pthread_mutexattr_destroy (&atts);
36}
37
38CriticalSection::~CriticalSection() noexcept { pthread_mutex_destroy (&lock); }
39void CriticalSection::enter() const noexcept { pthread_mutex_lock (&lock); }
40bool CriticalSection::tryEnter() const noexcept { return pthread_mutex_trylock (&lock) == 0; }
41void CriticalSection::exit() const noexcept { pthread_mutex_unlock (&lock); }
42
43//==============================================================================
44void JUCE_CALLTYPE Thread::sleep (int millisecs)
45{
46 struct timespec time;
47 time.tv_sec = millisecs / 1000;
48 time.tv_nsec = (millisecs % 1000) * 1000000;
49 nanosleep (&time, nullptr);
50}
51
53{
54 #if JUCE_ANDROID
55 _exit (EXIT_FAILURE);
56 #else
57 std::_Exit (EXIT_FAILURE);
58 #endif
59}
60
61
62#if JUCE_MAC || JUCE_LINUX || JUCE_BSD
63bool Process::setMaxNumberOfFileHandles (int newMaxNumber) noexcept
64{
65 rlimit lim;
66
67 if (getrlimit (RLIMIT_NOFILE, &lim) == 0)
68 {
69 if (newMaxNumber <= 0 && lim.rlim_cur == RLIM_INFINITY && lim.rlim_max == RLIM_INFINITY)
70 return true;
71
72 if (newMaxNumber > 0 && lim.rlim_cur >= (rlim_t) newMaxNumber)
73 return true;
74 }
75
76 lim.rlim_cur = lim.rlim_max = newMaxNumber <= 0 ? RLIM_INFINITY : (rlim_t) newMaxNumber;
77 return setrlimit (RLIMIT_NOFILE, &lim) == 0;
78}
79
80struct MaxNumFileHandlesInitialiser
81{
82 MaxNumFileHandlesInitialiser() noexcept
83 {
84 #ifndef JUCE_PREFERRED_MAX_FILE_HANDLES
85 enum { JUCE_PREFERRED_MAX_FILE_HANDLES = 8192 };
86 #endif
87
88 // Try to give our app a decent number of file handles by default
89 if (! Process::setMaxNumberOfFileHandles (0))
90 {
91 for (int num = JUCE_PREFERRED_MAX_FILE_HANDLES; num > 256; num -= 1024)
92 if (Process::setMaxNumberOfFileHandles (num))
93 break;
94 }
95 }
96};
97
98static MaxNumFileHandlesInitialiser maxNumFileHandlesInitialiser;
99#endif
100
101//==============================================================================
102#if JUCE_ALLOW_STATIC_NULL_VARIABLES
103
104JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
105
106const juce_wchar File::separator = '/';
107const StringRef File::separatorString ("/");
108
110
111#endif
112
115
116
117//==============================================================================
119{
120 HeapBlock<char> heapBuffer;
121
122 char localBuffer[1024];
123 auto cwd = getcwd (localBuffer, sizeof (localBuffer) - 1);
124 size_t bufferSize = 4096;
125
126 while (cwd == nullptr && errno == ERANGE)
127 {
128 heapBuffer.malloc (bufferSize);
129 cwd = getcwd (heapBuffer, bufferSize - 1);
130 bufferSize += 1024;
131 }
132
133 return File (CharPointer_UTF8 (cwd));
134}
135
137{
138 return chdir (getFullPathName().toUTF8()) == 0;
139}
140
141//==============================================================================
142// The unix siginterrupt function is deprecated - this does the same job.
143int juce_siginterrupt (int sig, int flag)
144{
145 #if JUCE_WASM
146 ignoreUnused (sig, flag);
147 return 0;
148 #else
149 #if JUCE_ANDROID
150 using juce_sigactionflags_type = unsigned long;
151 #else
152 using juce_sigactionflags_type = int;
153 #endif
154
155 struct ::sigaction act;
156 (void) ::sigaction (sig, nullptr, &act);
157
158 if (flag != 0)
159 act.sa_flags &= static_cast<juce_sigactionflags_type> (~SA_RESTART);
160 else
161 act.sa_flags |= static_cast<juce_sigactionflags_type> (SA_RESTART);
162
163 return ::sigaction (sig, &act, nullptr);
164 #endif
165}
166
167//==============================================================================
168namespace
169{
170 #if JUCE_LINUX || (JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T) // (this iOS stuff is to avoid a simulator bug)
171 using juce_statStruct = struct stat64;
172 #define JUCE_STAT stat64
173 #else
174 using juce_statStruct = struct stat;
175 #define JUCE_STAT stat
176 #endif
177
178 bool juce_stat (const String& fileName, juce_statStruct& info)
179 {
180 return fileName.isNotEmpty()
181 && JUCE_STAT (fileName.toUTF8(), &info) == 0;
182 }
183
184 #if ! JUCE_WASM
185 // if this file doesn't exist, find a parent of it that does..
186 bool juce_doStatFS (File f, struct statfs& result)
187 {
188 for (int i = 5; --i >= 0;)
189 {
190 if (f.exists())
191 break;
192
193 f = f.getParentDirectory();
194 }
195
196 return statfs (f.getFullPathName().toUTF8(), &result) == 0;
197 }
198
199 #if JUCE_MAC || JUCE_IOS
200 static int64 getCreationTime (const juce_statStruct& s) noexcept { return (int64) s.st_birthtime; }
201 #else
202 static int64 getCreationTime (const juce_statStruct& s) noexcept { return (int64) s.st_ctime; }
203 #endif
204
205 void updateStatInfoForFile (const String& path, bool* isDir, int64* fileSize,
206 Time* modTime, Time* creationTime, bool* isReadOnly)
207 {
208 if (isDir != nullptr || fileSize != nullptr || modTime != nullptr || creationTime != nullptr)
209 {
210 juce_statStruct info;
211 const bool statOk = juce_stat (path, info);
212
213 if (isDir != nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0);
214 if (fileSize != nullptr) *fileSize = statOk ? (int64) info.st_size : 0;
215 if (modTime != nullptr) *modTime = Time (statOk ? (int64) info.st_mtime * 1000 : 0);
216 if (creationTime != nullptr) *creationTime = Time (statOk ? getCreationTime (info) * 1000 : 0);
217 }
218
219 if (isReadOnly != nullptr)
220 *isReadOnly = access (path.toUTF8(), W_OK) != 0;
221 }
222 #endif
223
224 Result getResultForErrno()
225 {
226 return Result::fail (String (strerror (errno)));
227 }
228
229 Result getResultForReturnValue (int value)
230 {
231 return value == -1 ? getResultForErrno() : Result::ok();
232 }
233
234 int getFD (void* handle) noexcept { return (int) (pointer_sized_int) handle; }
235 void* fdToVoidPointer (int fd) noexcept { return (void*) (pointer_sized_int) fd; }
236}
237
239{
240 juce_statStruct info;
241
242 return fullPath.isNotEmpty()
243 && (juce_stat (fullPath, info) && ((info.st_mode & S_IFDIR) != 0));
244}
245
246bool File::exists() const
247{
248 return fullPath.isNotEmpty()
249 && access (fullPath.toUTF8(), F_OK) == 0;
250}
251
253{
254 return exists() && ! isDirectory();
255}
256
258{
259 juce_statStruct info;
260 return juce_stat (fullPath, info) ? info.st_size : 0;
261}
262
264{
265 juce_statStruct info;
266 return juce_stat (fullPath, info) ? (uint64) info.st_ino : 0;
267}
268
270{
271 #if JUCE_LINUX || JUCE_BSD
272 return geteuid() == 0;
273 #else
274 return false;
275 #endif
276}
277
278//==============================================================================
280{
281 if (exists())
283 || access (fullPath.toUTF8(), W_OK) == 0);
284
285 if ((! isDirectory()) && fullPath.containsChar (getSeparatorChar()))
286 return getParentDirectory().hasWriteAccess();
287
288 return false;
289}
290
292{
293 return fullPath.isNotEmpty()
294 && access (fullPath.toUTF8(), R_OK) == 0;
295}
296
297static bool setFileModeFlags (const String& fullPath, mode_t flags, bool shouldSet) noexcept
298{
299 juce_statStruct info;
300
301 if (! juce_stat (fullPath, info))
302 return false;
303
304 info.st_mode &= 0777;
305
306 if (shouldSet)
307 info.st_mode |= flags;
308 else
309 info.st_mode &= ~flags;
310
311 return chmod (fullPath.toUTF8(), (mode_t) info.st_mode) == 0;
312}
313
314bool File::setFileReadOnlyInternal (bool shouldBeReadOnly) const
315{
316 // Hmm.. should we give global write permission or just the current user?
317 return setFileModeFlags (fullPath, S_IWUSR | S_IWGRP | S_IWOTH, ! shouldBeReadOnly);
318}
319
320bool File::setFileExecutableInternal (bool shouldBeExecutable) const
321{
322 return setFileModeFlags (fullPath, S_IXUSR | S_IXGRP | S_IXOTH, shouldBeExecutable);
323}
324
325void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int64& creationTime) const
326{
327 modificationTime = 0;
328 accessTime = 0;
329 creationTime = 0;
330
331 juce_statStruct info;
332
333 if (juce_stat (fullPath, info))
334 {
335 #if JUCE_MAC || (JUCE_IOS && __DARWIN_ONLY_64_BIT_INO_T)
336 modificationTime = (int64) info.st_mtimespec.tv_sec * 1000 + info.st_mtimespec.tv_nsec / 1000000;
337 accessTime = (int64) info.st_atimespec.tv_sec * 1000 + info.st_atimespec.tv_nsec / 1000000;
338 creationTime = (int64) info.st_birthtimespec.tv_sec * 1000 + info.st_birthtimespec.tv_nsec / 1000000;
339 #else
340 modificationTime = (int64) info.st_mtime * 1000;
341 accessTime = (int64) info.st_atime * 1000;
342 #if JUCE_IOS
343 creationTime = (int64) info.st_birthtime * 1000;
344 #else
345 creationTime = (int64) info.st_ctime * 1000;
346 #endif
347 #endif
348 }
349}
350
351bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 /*creationTime*/) const
352{
353 #if ! JUCE_WASM
354 juce_statStruct info;
355
356 if ((modificationTime != 0 || accessTime != 0) && juce_stat (fullPath, info))
357 {
358 #if JUCE_MAC || (JUCE_IOS && __DARWIN_ONLY_64_BIT_INO_T)
359 struct timeval times[2];
360
361 bool setModificationTime = (modificationTime != 0);
362 bool setAccessTime = (accessTime != 0);
363
364 times[0].tv_sec = setAccessTime ? static_cast<__darwin_time_t> (accessTime / 1000)
365 : info.st_atimespec.tv_sec;
366
367 times[0].tv_usec = setAccessTime ? static_cast<__darwin_suseconds_t> ((accessTime % 1000) * 1000)
368 : static_cast<__darwin_suseconds_t> (info.st_atimespec.tv_nsec / 1000);
369
370 times[1].tv_sec = setModificationTime ? static_cast<__darwin_time_t> (modificationTime / 1000)
371 : info.st_mtimespec.tv_sec;
372
373 times[1].tv_usec = setModificationTime ? static_cast<__darwin_suseconds_t> ((modificationTime % 1000) * 1000)
374 : static_cast<__darwin_suseconds_t> (info.st_mtimespec.tv_nsec / 1000);
375
376 return utimes (fullPath.toUTF8(), times) == 0;
377 #else
378 struct utimbuf times;
379 times.actime = accessTime != 0 ? static_cast<time_t> (accessTime / 1000) : static_cast<time_t> (info.st_atime);
380 times.modtime = modificationTime != 0 ? static_cast<time_t> (modificationTime / 1000) : static_cast<time_t> (info.st_mtime);
381
382 return utime (fullPath.toUTF8(), &times) == 0;
383 #endif
384 }
385 #endif
386
387 return false;
388}
389
391{
392 if (! isSymbolicLink())
393 {
394 if (! exists())
395 return true;
396
397 if (isDirectory())
398 return rmdir (fullPath.toUTF8()) == 0;
399 }
400
401 return remove (fullPath.toUTF8()) == 0;
402}
403
404bool File::moveInternal (const File& dest) const
405{
406 if (rename (fullPath.toUTF8(), dest.getFullPathName().toUTF8()) == 0)
407 return true;
408
409 if (hasWriteAccess() && copyInternal (dest))
410 {
411 if (deleteFile())
412 return true;
413
414 dest.deleteFile();
415 }
416
417 return false;
418}
419
420bool File::replaceInternal (const File& dest) const
421{
422 return moveInternal (dest);
423}
424
426{
427 return getResultForReturnValue (mkdir (fileName.toUTF8(), 0777));
428}
429
430//==============================================================================
432{
433 if (handle != nullptr && lseek (getFD (handle), (off_t) pos, SEEK_SET) == pos)
434 return pos;
435
436 return -1;
437}
438
440{
441 auto f = open (file.getFullPathName().toUTF8(), O_RDONLY);
442
443 if (f != -1)
444 fileHandle = fdToVoidPointer (f);
445 else
446 status = getResultForErrno();
447}
448
450{
451 if (fileHandle != nullptr)
452 close (getFD (fileHandle));
453}
454
455size_t FileInputStream::readInternal (void* buffer, size_t numBytes)
456{
457 ssize_t result = 0;
458
459 if (fileHandle != nullptr)
460 {
461 result = ::read (getFD (fileHandle), buffer, numBytes);
462
463 if (result < 0)
464 {
465 status = getResultForErrno();
466 result = 0;
467 }
468 }
469
470 return (size_t) result;
471}
472
473//==============================================================================
475{
476 if (file.exists())
477 {
478 auto f = open (file.getFullPathName().toUTF8(), O_RDWR);
479
480 if (f != -1)
481 {
483
484 if (currentPosition >= 0)
485 {
486 fileHandle = fdToVoidPointer (f);
487 }
488 else
489 {
490 status = getResultForErrno();
491 close (f);
492 }
493 }
494 else
495 {
496 status = getResultForErrno();
497 }
498 }
499 else
500 {
501 auto f = open (file.getFullPathName().toUTF8(), O_RDWR | O_CREAT, 00644);
502
503 if (f != -1)
504 fileHandle = fdToVoidPointer (f);
505 else
506 status = getResultForErrno();
507 }
508}
509
511{
512 if (fileHandle != nullptr)
513 {
514 close (getFD (fileHandle));
515 fileHandle = nullptr;
516 }
517}
518
519ssize_t FileOutputStream::writeInternal (const void* data, size_t numBytes)
520{
521 if (fileHandle == nullptr)
522 return 0;
523
524 auto result = ::write (getFD (fileHandle), data, numBytes);
525
526 if (result == -1)
527 status = getResultForErrno();
528
529 return (ssize_t) result;
530}
531
532#ifndef JUCE_ANDROID
534{
535 if (fileHandle != nullptr && fsync (getFD (fileHandle)) == -1)
536 status = getResultForErrno();
537}
538#endif
539
541{
542 if (fileHandle == nullptr)
543 return status;
544
545 flush();
546 return getResultForReturnValue (ftruncate (getFD (fileHandle), (off_t) currentPosition));
547}
548
549//==============================================================================
551{
552 if (auto s = ::getenv (name.toUTF8()))
553 return String::fromUTF8 (s);
554
555 return defaultValue;
556}
557
558//==============================================================================
559#if ! JUCE_WASM
561{
563
564 if (range.getStart() > 0)
565 {
566 auto pageSize = sysconf (_SC_PAGE_SIZE);
567 range.setStart (range.getStart() - (range.getStart() % pageSize));
568 }
569
570 auto filename = file.getFullPathName().toUTF8();
571
572 if (mode == readWrite)
573 fileHandle = open (filename, O_CREAT | O_RDWR, 00644);
574 else
575 fileHandle = open (filename, O_RDONLY);
576
577 if (fileHandle != -1)
578 {
579 auto m = mmap (nullptr, (size_t) range.getLength(),
580 mode == readWrite ? (PROT_READ | PROT_WRITE) : PROT_READ,
581 exclusive ? MAP_PRIVATE : MAP_SHARED, fileHandle,
582 (off_t) range.getStart());
583
584 if (m != MAP_FAILED)
585 {
586 address = m;
587 madvise (m, (size_t) range.getLength(), MADV_SEQUENTIAL);
588 }
589 else
590 {
592 }
593
594 close (fileHandle);
595 fileHandle = 0;
596 }
597}
598
600{
601 if (address != nullptr)
602 munmap (address, (size_t) range.getLength());
603
604 if (fileHandle != 0)
605 close (fileHandle);
606}
607
608//==============================================================================
611{
612 struct DLAddrReader
613 {
614 static String getFilename()
615 {
616 Dl_info exeInfo;
617
618 auto localSymbol = (void*) juce_getExecutableFile;
619 dladdr (localSymbol, &exeInfo);
620
621 const CharPointer_UTF8 filename (exeInfo.dli_fname);
622
623 // if the filename is absolute simply return it
625 return filename;
626
627 // if the filename is relative construct from CWD
628 if (filename[0] == '.')
630
631 // filename is abstract, look up in PATH
632 if (const char* const envpath = ::getenv ("PATH"))
633 {
634 StringArray paths (StringArray::fromTokens (envpath, ":", ""));
635
636 for (int i=paths.size(); --i>=0;)
637 {
638 const File filepath (File (paths[i]).getChildFile (filename));
639
640 if (filepath.existsAsFile())
641 return filepath.getFullPathName();
642 }
643 }
644
645 // if we reach this, we failed to find ourselves...
647 return filename;
648 }
649 };
650
651 static String filename = DLAddrReader::getFilename();
652 return filename;
653}
654
655//==============================================================================
657{
658 struct statfs buf;
659
660 if (juce_doStatFS (*this, buf))
661 return (int64) buf.f_bsize * (int64) buf.f_bavail; // Note: this returns space available to non-super user
662
663 return 0;
664}
665
667{
668 struct statfs buf;
669
670 if (juce_doStatFS (*this, buf))
671 return (int64) buf.f_bsize * (int64) buf.f_blocks;
672
673 return 0;
674}
675
677{
678 #if JUCE_MAC
679 struct VolAttrBuf
680 {
681 u_int32_t length;
682 attrreference_t mountPointRef;
683 char mountPointSpace[MAXPATHLEN];
684 } attrBuf;
685
686 struct attrlist attrList;
687 zerostruct (attrList); // (can't use "= {}" on this object because it's a C struct)
688 attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
689 attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_NAME;
690
691 File f (*this);
692
693 for (;;)
694 {
695 if (getattrlist (f.getFullPathName().toUTF8(), &attrList, &attrBuf, sizeof (attrBuf), 0) == 0)
696 return String::fromUTF8 (((const char*) &attrBuf.mountPointRef) + attrBuf.mountPointRef.attr_dataoffset,
697 (int) attrBuf.mountPointRef.attr_length);
698
699 auto parent = f.getParentDirectory();
700
701 if (f == parent)
702 break;
703
704 f = parent;
705 }
706 #endif
707
708 return {};
709}
710
712{
713 return 0;
714}
715
716#endif
717
718//==============================================================================
719#if ! JUCE_IOS
720void juce_runSystemCommand (const String&);
721void juce_runSystemCommand (const String& command)
722{
723 int result = system (command.toUTF8());
725}
726
727String juce_getOutputFromCommand (const String&);
729{
730 // slight bodge here, as we just pipe the output into a temp file and read it...
733
734 juce_runSystemCommand (command + " > " + tempFile.getFullPathName());
735
736 auto result = tempFile.loadFileAsString();
737 tempFile.deleteFile();
738 return result;
739}
740#endif
741
742//==============================================================================
743#if JUCE_IOS
744class InterProcessLock::Pimpl
745{
746public:
747 Pimpl (const String&, int) {}
748
749 int handle = 1, refCount = 1; // On iOS just fake success..
750};
751
752#else
753
755{
756public:
757 Pimpl (const String& lockName, int timeOutMillisecs)
758 {
759 #if JUCE_MAC
760 if (! createLockFile (File ("~/Library/Caches/com.juce.locks").getChildFile (lockName), timeOutMillisecs))
761 // Fallback if the user's home folder is on a network drive with no ability to lock..
762 createLockFile (File ("/tmp/com.juce.locks").getChildFile (lockName), timeOutMillisecs);
763
764 #else
765 File tempFolder ("/var/tmp");
766
767 if (! tempFolder.isDirectory())
768 tempFolder = "/tmp";
769
770 createLockFile (tempFolder.getChildFile (lockName), timeOutMillisecs);
771 #endif
772 }
773
775 {
776 closeFile();
777 }
778
779 bool createLockFile (const File& file, int timeOutMillisecs)
780 {
781 file.create();
782 handle = open (file.getFullPathName().toUTF8(), O_RDWR);
783
784 if (handle != 0)
785 {
786 struct flock fl;
787 zerostruct (fl);
788
789 fl.l_whence = SEEK_SET;
790 fl.l_type = F_WRLCK;
791
792 auto endTime = Time::currentTimeMillis() + timeOutMillisecs;
793
794 for (;;)
795 {
796 auto result = fcntl (handle, F_SETLK, &fl);
797
798 if (result >= 0)
799 return true;
800
801 auto error = errno;
802
803 if (error != EINTR)
804 {
805 if (error == EBADF || error == ENOTSUP)
806 return false;
807
808 if (timeOutMillisecs == 0
809 || (timeOutMillisecs > 0 && Time::currentTimeMillis() >= endTime))
810 break;
811
812 Thread::sleep (10);
813 }
814 }
815 }
816
817 closeFile();
818 return true; // only false if there's a file system error. Failure to lock still returns true.
819 }
820
822 {
823 if (handle != 0)
824 {
825 struct flock fl;
826 zerostruct (fl);
827
828 fl.l_whence = SEEK_SET;
829 fl.l_type = F_UNLCK;
830
831 while (! (fcntl (handle, F_SETLKW, &fl) >= 0 || errno != EINTR))
832 {}
833
834 close (handle);
835 handle = 0;
836 }
837 }
838
839 int handle = 0, refCount = 1;
840};
841#endif
842
844{
845}
846
850
851bool InterProcessLock::enter (int timeOutMillisecs)
852{
853 const ScopedLock sl (lock);
854
855 if (pimpl == nullptr)
856 {
857 pimpl.reset (new Pimpl (name, timeOutMillisecs));
858
859 if (pimpl->handle == 0)
860 pimpl.reset();
861 }
862 else
863 {
864 pimpl->refCount++;
865 }
866
867 return pimpl != nullptr;
868}
869
871{
872 const ScopedLock sl (lock);
873
874 // Trying to release the lock too many times!
875 jassert (pimpl != nullptr);
876
877 if (pimpl != nullptr && --(pimpl->refCount) == 0)
878 pimpl.reset();
879}
880
881//==============================================================================
882#if JUCE_ANDROID
883extern JavaVM* androidJNIJavaVM;
884#endif
885
886static void* threadEntryProc (void* userData)
887{
888 auto* myself = static_cast<Thread*> (userData);
889
891 {
892 juce_threadEntryPoint (myself);
893 }
894
895 #if JUCE_ANDROID
896 if (androidJNIJavaVM != nullptr)
897 {
898 void* env = nullptr;
899 androidJNIJavaVM->GetEnv(&env, JNI_VERSION_1_2);
900
901 // only detach if we have actually been attached
902 if (env != nullptr)
903 androidJNIJavaVM->DetachCurrentThread();
904 }
905 #endif
906
907 return nullptr;
908}
909
910#if JUCE_ANDROID && JUCE_MODULE_AVAILABLE_juce_audio_devices && (JUCE_USE_ANDROID_OPENSLES || JUCE_USE_ANDROID_OBOE)
911 #define JUCE_ANDROID_REALTIME_THREAD_AVAILABLE 1
912#endif
913
914#if JUCE_ANDROID_REALTIME_THREAD_AVAILABLE
915extern pthread_t juce_createRealtimeAudioThread (void* (*entry) (void*), void* userPtr);
916#endif
917
919{
920 #if JUCE_ANDROID
921 if (isAndroidRealtimeThread)
922 {
923 #if JUCE_ANDROID_REALTIME_THREAD_AVAILABLE
924 threadHandle = (void*) juce_createRealtimeAudioThread (threadEntryProc, this);
926
927 return;
928 #else
930 #endif
931 }
932 #endif
933
934 threadHandle = {};
935 pthread_t handle = {};
936 pthread_attr_t attr;
937 pthread_attr_t* attrPtr = nullptr;
938
939 if (pthread_attr_init (&attr) == 0)
940 {
941 attrPtr = &attr;
942 pthread_attr_setstacksize (attrPtr, threadStackSize);
943 }
944
945
946 if (pthread_create (&handle, attrPtr, threadEntryProc, this) == 0)
947 {
948 pthread_detach (handle);
949 threadHandle = (void*) handle;
951 }
952
953 if (attrPtr != nullptr)
954 pthread_attr_destroy (attrPtr);
955}
956
958{
959 threadId = {};
960 threadHandle = {};
961}
962
964{
965 if (threadHandle.get() != nullptr)
966 {
967 #if JUCE_ANDROID
968 jassertfalse; // pthread_cancel not available!
969 #else
970 pthread_cancel ((pthread_t) threadHandle.get());
971 #endif
972 }
973}
974
976{
977 #if JUCE_IOS || JUCE_MAC
979 {
980 [[NSThread currentThread] setName: juceStringToNS (name)];
981 }
982 #elif JUCE_LINUX || JUCE_BSD || JUCE_ANDROID
983 #if (JUCE_BSD \
984 || (JUCE_LINUX && (__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2012) \
985 || (JUCE_ANDROID && __ANDROID_API__ >= 9))
986 pthread_setname_np (pthread_self(), name.toRawUTF8());
987 #else
988 prctl (PR_SET_NAME, name.toRawUTF8(), 0, 0, 0);
989 #endif
990 #endif
991}
992
993bool Thread::setThreadPriority (void* handle, int priority)
994{
995 constexpr auto maxInputPriority = 10;
996
997 #if JUCE_LINUX || JUCE_BSD
998 constexpr auto lowestRrPriority = 8;
999 #else
1000 constexpr auto lowestRrPriority = 0;
1001 #endif
1002
1003 struct sched_param param;
1004 int policy;
1005
1006 if (handle == nullptr)
1007 handle = (void*) pthread_self();
1008
1009 if (pthread_getschedparam ((pthread_t) handle, &policy, &param) != 0)
1010 return false;
1011
1012 policy = priority < lowestRrPriority ? SCHED_OTHER : SCHED_RR;
1013
1014 const auto minPriority = sched_get_priority_min (policy);
1015 const auto maxPriority = sched_get_priority_max (policy);
1016
1017 param.sched_priority = [&]
1018 {
1019 if (policy == SCHED_OTHER)
1020 return 0;
1021
1022 return jmap (priority, lowestRrPriority, maxInputPriority, minPriority, maxPriority);
1023 }();
1024
1025 return pthread_setschedparam ((pthread_t) handle, policy, &param) == 0;
1026}
1027
1029{
1030 return (ThreadID) pthread_self();
1031}
1032
1034{
1035 sched_yield();
1036}
1037
1038//==============================================================================
1039/* Remove this macro if you're having problems compiling the cpu affinity
1040 calls (the API for these has changed about quite a bit in various Linux
1041 versions, and a lot of distros seem to ship with obsolete versions)
1042*/
1043#if defined (CPU_ISSET) && ! defined (SUPPORT_AFFINITIES)
1044 #define SUPPORT_AFFINITIES 1
1045#endif
1046
1048{
1049 #if SUPPORT_AFFINITIES
1050 cpu_set_t affinity;
1051 CPU_ZERO (&affinity);
1052
1053 for (int i = 0; i < 32; ++i)
1054 if ((affinityMask & (uint32) (1 << i)) != 0)
1055 CPU_SET ((size_t) i, &affinity);
1056
1057 #if (! JUCE_ANDROID) && ((! (JUCE_LINUX || JUCE_BSD)) || ((__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2004))
1058 pthread_setaffinity_np (pthread_self(), sizeof (cpu_set_t), &affinity);
1059 #elif JUCE_ANDROID
1060 sched_setaffinity (gettid(), sizeof (cpu_set_t), &affinity);
1061 #else
1062 // NB: this call isn't really correct because it sets the affinity of the process,
1063 // (getpid) not the thread (not gettid). But it's included here as a fallback for
1064 // people who are using ridiculously old versions of glibc
1065 sched_setaffinity (getpid(), sizeof (cpu_set_t), &affinity);
1066 #endif
1067
1068 sched_yield();
1069
1070 #else
1071 // affinities aren't supported because either the appropriate header files weren't found,
1072 // or the SUPPORT_AFFINITIES macro was turned off
1075 #endif
1076}
1077
1078//==============================================================================
1079#if ! JUCE_WASM
1081{
1082 close();
1083 handle = dlopen (name.isEmpty() ? nullptr : name.toUTF8().getAddress(), RTLD_LOCAL | RTLD_NOW);
1084 return handle != nullptr;
1085}
1086
1088{
1089 if (handle != nullptr)
1090 {
1091 dlclose (handle);
1092 handle = nullptr;
1093 }
1094}
1095
1096void* DynamicLibrary::getFunction (const String& functionName) noexcept
1097{
1098 return handle != nullptr ? dlsym (handle, functionName.toUTF8()) : nullptr;
1099}
1100
1101//==============================================================================
1102#if JUCE_LINUX || JUCE_ANDROID
1103static String readPosixConfigFileValue (const char* file, const char* key)
1104{
1105 StringArray lines;
1106 File (file).readLines (lines);
1107
1108 for (int i = lines.size(); --i >= 0;) // (NB - it's important that this runs in reverse order)
1109 if (lines[i].upToFirstOccurrenceOf (":", false, false).trim().equalsIgnoreCase (key))
1110 return lines[i].fromFirstOccurrenceOf (":", false, false).trim();
1111
1112 return {};
1113}
1114#endif
1115
1116
1117//==============================================================================
1119{
1120public:
1121 ActiveProcess (const StringArray& arguments, int streamFlags)
1122 {
1123 auto exe = arguments[0].unquoted();
1124
1125 // Looks like you're trying to launch a non-existent exe or a folder (perhaps on OSX
1126 // you're trying to launch the .app folder rather than the actual binary inside it?)
1127 jassert (File::getCurrentWorkingDirectory().getChildFile (exe).existsAsFile()
1128 || ! exe.containsChar (File::getSeparatorChar()));
1129
1130 int pipeHandles[2] = {};
1131
1132 if (pipe (pipeHandles) == 0)
1133 {
1135 for (auto& arg : arguments)
1136 if (arg.isNotEmpty())
1137 argv.add (const_cast<char*> (arg.toRawUTF8()));
1138
1139 argv.add (nullptr);
1140
1141#if JUCE_USE_VFORK
1142 const pid_t result = vfork();
1143#else
1144 const pid_t result = fork();
1145#endif
1146
1147 if (result < 0)
1148 {
1149 close (pipeHandles[0]);
1150 close (pipeHandles[1]);
1151 }
1152 else if (result == 0)
1153 {
1154#if ! JUCE_USE_VFORK
1155 // we're the child process..
1156 close (pipeHandles[0]); // close the read handle
1157
1158 if ((streamFlags & wantStdOut) != 0)
1159 dup2 (pipeHandles[1], STDOUT_FILENO); // turns the pipe into stdout
1160 else
1161 dup2 (open ("/dev/null", O_WRONLY), STDOUT_FILENO);
1162
1163 if ((streamFlags & wantStdErr) != 0)
1164 dup2 (pipeHandles[1], STDERR_FILENO);
1165 else
1166 dup2 (open ("/dev/null", O_WRONLY), STDERR_FILENO);
1167
1168 close (pipeHandles[1]);
1169#endif
1170
1171 if (execvp (exe.toRawUTF8(), argv.getRawDataPointer()) < 0)
1172 _exit (-1);
1173 }
1174 else
1175 {
1176 // we're the parent process..
1177 childPID = result;
1178 pipeHandle = pipeHandles[0];
1179 close (pipeHandles[1]); // close the write handle
1180 }
1181 }
1182 }
1183
1185 {
1186 if (readHandle != nullptr)
1187 fclose (readHandle);
1188
1189 if (pipeHandle != 0)
1190 close (pipeHandle);
1191 }
1192
1194 {
1195 if (childPID == 0)
1196 return false;
1197
1198 int childState = 0;
1199 auto pid = waitpid (childPID, &childState, WNOHANG);
1200
1201 if (pid == 0)
1202 return true;
1203
1204 if (WIFEXITED (childState))
1205 {
1206 exitCode = WEXITSTATUS (childState);
1207 return false;
1208 }
1209
1210 return ! WIFSIGNALED (childState);
1211 }
1212
1213 int read (void* dest, int numBytes) noexcept
1214 {
1215 jassert (dest != nullptr && numBytes > 0);
1216
1217 #ifdef fdopen
1218 #error // some crazy 3rd party headers (e.g. zlib) define this function as NULL!
1219 #endif
1220
1221 if (readHandle == nullptr && childPID != 0)
1222 readHandle = fdopen (pipeHandle, "r");
1223
1224 if (readHandle != nullptr)
1225 {
1226 for (;;)
1227 {
1228 auto numBytesRead = (int) fread (dest, 1, (size_t) numBytes, readHandle);
1229
1230 if (numBytesRead > 0 || feof (readHandle))
1231 return numBytesRead;
1232
1233 // signal occurred during fread() so try again
1234 if (ferror (readHandle) && errno == EINTR)
1235 continue;
1236
1237 break;
1238 }
1239 }
1240
1241 return 0;
1242 }
1243
1245 {
1246 return ::kill (childPID, SIGKILL) == 0;
1247 }
1248
1250 {
1251 if (exitCode >= 0)
1252 return (uint32) exitCode;
1253
1254 if (childPID != 0)
1255 {
1256 int childState = 0;
1257 auto pid = waitpid (childPID, &childState, WNOHANG);
1258
1259 if (pid >= 0 && WIFEXITED (childState))
1260 {
1261 exitCode = WEXITSTATUS (childState);
1262 return (uint32) exitCode;
1263 }
1264 }
1265
1266 return 0;
1267 }
1268
1270 {
1271 return childPID;
1272 }
1273
1274 int childPID = 0;
1275 int pipeHandle = 0;
1276 int exitCode = -1;
1277 FILE* readHandle = {};
1278
1280};
1281
1282bool ChildProcess::start (const String& command, int streamFlags)
1283{
1284 return start (StringArray::fromTokens (command, true), streamFlags);
1285}
1286
1287bool ChildProcess::start (const StringArray& args, int streamFlags)
1288{
1289 if (args.size() == 0)
1290 return false;
1291
1292 activeProcess.reset (new ActiveProcess (args, streamFlags));
1293
1294 if (activeProcess->childPID == 0)
1295 activeProcess.reset();
1296
1297 return activeProcess != nullptr;
1298}
1299
1300#endif
1301
1302//==============================================================================
1304{
1306 : owner (t)
1307 {}
1308
1310 {
1311 jassert (periodMs == 0);
1312 stop();
1313 }
1314
1315 void start (int newPeriod)
1316 {
1317 if (periodMs == newPeriod)
1318 return;
1319
1320 if (thread.get_id() == std::this_thread::get_id())
1321 {
1322 periodMs = newPeriod;
1323 return;
1324 }
1325
1326 stop();
1327
1328 periodMs = newPeriod;
1329
1330 thread = std::thread ([this, newPeriod]
1331 {
1332 setThisThreadToRealtime ((uint64) newPeriod);
1333
1334 auto lastPeriod = periodMs.load();
1335 Clock clock (lastPeriod);
1336
1337 std::unique_lock<std::mutex> unique_lock (timerMutex);
1338
1339 while (periodMs != 0)
1340 {
1341 clock.next();
1342 while (periodMs != 0 && clock.wait (stopCond, unique_lock));
1343
1344 if (periodMs == 0)
1345 break;
1346
1347 owner.hiResTimerCallback();
1348
1349 auto nextPeriod = periodMs.load();
1350
1351 if (lastPeriod != nextPeriod)
1352 {
1353 lastPeriod = nextPeriod;
1354 clock = Clock (lastPeriod);
1355 }
1356 }
1357
1358 periodMs = 0;
1359 });
1360 }
1361
1362 void stop()
1363 {
1364 periodMs = 0;
1365
1366 const auto thread_id = thread.get_id();
1367
1368 if (thread_id == std::thread::id() || thread_id == std::this_thread::get_id())
1369 return;
1370
1371 {
1372 std::unique_lock<std::mutex> unique_lock (timerMutex);
1373 stopCond.notify_one();
1374 }
1375
1376 thread.join();
1377 }
1378
1380 std::atomic<int> periodMs { 0 };
1381
1382private:
1383 std::thread thread;
1384 std::condition_variable stopCond;
1385 std::mutex timerMutex;
1386
1387 class Clock
1388 {
1389 public:
1390 explicit Clock (std::chrono::steady_clock::rep millis) noexcept
1391 : time (std::chrono::steady_clock::now()),
1392 delta (std::chrono::milliseconds (millis))
1393 {}
1394
1395 bool wait (std::condition_variable& cond, std::unique_lock<std::mutex>& lock) noexcept
1396 {
1397 return cond.wait_until (lock, time) != std::cv_status::timeout;
1398 }
1399
1401 {
1402 time += delta;
1403 }
1404
1405 private:
1406 std::chrono::time_point<std::chrono::steady_clock> time;
1407 std::chrono::steady_clock::duration delta;
1408 };
1409
1411 {
1412 const auto thread = pthread_self();
1413
1414 #if JUCE_MAC || JUCE_IOS
1415 mach_timebase_info_data_t timebase;
1416 mach_timebase_info (&timebase);
1417
1418 const auto ticksPerMs = ((double) timebase.denom * 1000000.0) / (double) timebase.numer;
1419 const auto periodTicks = (uint32_t) jmin ((double) std::numeric_limits<uint32_t>::max(), periodMs * ticksPerMs);
1420
1421 thread_time_constraint_policy_data_t policy;
1422 policy.period = periodTicks;
1423 policy.computation = jmin ((uint32_t) 50000, policy.period);
1424 policy.constraint = policy.period;
1425 policy.preemptible = true;
1426
1427 return thread_policy_set (pthread_mach_thread_np (thread),
1428 THREAD_TIME_CONSTRAINT_POLICY,
1429 (thread_policy_t) &policy,
1430 THREAD_TIME_CONSTRAINT_POLICY_COUNT) == KERN_SUCCESS;
1431
1432 #else
1434 struct sched_param param;
1435 param.sched_priority = sched_get_priority_max (SCHED_RR);
1436 return pthread_setschedparam (thread, SCHED_RR, &param) == 0;
1437 #endif
1438 }
1439
1441};
1442
1443} // namespace juce
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
#define noexcept
Definition DistrhoDefines.h:72
std::chrono::steady_clock Clock
Definition NulEngine.cpp:29
float arg(const fft_t *freqs, off_t x)
Definition OscilGen.cpp:58
#define MAXPATHLEN
Definition asiolist.h:9
int64_t int64
Definition basics.h:91
Definition juce_posix_SharedCode.h:1119
bool start(const String &command, Type type=TypeAny)
Definition ChildProcess.cpp:361
bool existsAsFile() const
Definition File.cpp:1320
static File getCurrentWorkingDirectory()
Definition File.cpp:1395
bool deleteFile() const
Definition File.cpp:1358
void getFileTimesInternal(int64 &m, int64 &a, int64 &c) const
Definition File.cpp:1336
bool moveInternal(const File &) const
Definition File.cpp:1369
bool setFileReadOnlyInternal(bool) const
bool setAsCurrentWorkingDirectory() const
Definition File.cpp:1414
bool exists() const
Definition File.cpp:1314
bool isDirectory() const
Definition File.cpp:1306
int64 getSize() const
Definition File.cpp:1352
bool setFileExecutableInternal(bool) const
bool replaceInternal(const File &) const
Definition File.cpp:1385
Result createDirectoryInternal(const String &) const
Definition File.cpp:1390
static File getSpecialLocation(const SpecialLocationType type)
Definition File.cpp:1642
bool hasWriteAccess() const
Definition File.cpp:1325
static Result fail(const std::string &errorMessage) noexcept
Definition Result.cpp:58
Definition String.h:48
CharPointer_UTF8 toUTF8() const
Definition String.cpp:1906
bool isNotEmpty() const noexcept
Definition String.h:244
static String fromUTF8(const char *utf8buffer, int bufferSizeBytes=-1)
Definition String.cpp:1961
Definition juce_CharPointer_UTF8.h:35
Definition juce_posix_SharedCode.h:1119
int read(void *dest, int numBytes) noexcept
Definition juce_posix_SharedCode.h:1213
int getPID() const noexcept
Definition juce_posix_SharedCode.h:1269
FILE * readHandle
Definition juce_posix_SharedCode.h:1277
uint32 getExitCode() noexcept
Definition juce_posix_SharedCode.h:1249
int childPID
Definition juce_posix_SharedCode.h:1274
~ActiveProcess()
Definition juce_posix_SharedCode.h:1184
ActiveProcess(const StringArray &arguments, int streamFlags)
Definition juce_posix_SharedCode.h:1121
bool killProcess() const noexcept
Definition juce_posix_SharedCode.h:1244
bool isRunning() noexcept
Definition juce_posix_SharedCode.h:1193
int exitCode
Definition juce_posix_SharedCode.h:1276
int pipeHandle
Definition juce_posix_SharedCode.h:1275
std::unique_ptr< ActiveProcess > activeProcess
Definition juce_ChildProcess.h:109
bool tryEnter() const noexcept
Definition juce_posix_SharedCode.h:40
~CriticalSection() noexcept
Definition juce_posix_SharedCode.h:38
CriticalSection() noexcept
Definition juce_posix_SharedCode.h:26
pthread_mutex_t lock
Definition juce_CriticalSection.h:114
void enter() const noexcept
Definition juce_posix_SharedCode.h:39
void exit() const noexcept
Definition juce_posix_SharedCode.h:41
void * getFunction(const String &functionName) noexcept
Definition juce_posix_SharedCode.h:1096
void * handle
Definition juce_DynamicLibrary.h:81
bool open(const String &name)
Definition juce_posix_SharedCode.h:1080
void close()
Definition juce_posix_SharedCode.h:1087
Definition juce_File.h:45
int getVolumeSerialNumber() const
Definition juce_posix_SharedCode.h:711
bool isSymbolicLink() const
Definition juce_linux_CommonFile.cpp:58
bool copyInternal(const File &) const
Definition juce_linux_CommonFile.cpp:26
bool isDirectory() const
Definition juce_posix_SharedCode.h:238
static StringRef getSeparatorString()
Definition juce_posix_SharedCode.h:114
int64 getVolumeTotalSize() const
Definition juce_posix_SharedCode.h:666
int64 getBytesFreeOnVolume() const
Definition juce_posix_SharedCode.h:656
bool hasWriteAccess() const
Definition juce_posix_SharedCode.h:279
bool existsAsFile() const
Definition juce_posix_SharedCode.h:252
String fullPath
Definition juce_File.h:1147
const String & getFullPathName() const noexcept
Definition juce_File.h:153
File getChildFile(StringRef relativeOrAbsolutePath) const
Definition juce_File.cpp:412
void readLines(StringArray &destLines) const
Definition juce_File.cpp:558
static bool isAbsolutePath(StringRef path)
Definition juce_File.cpp:400
@ tempDirectory
Definition juce_File.h:913
File getNonexistentChildFile(const String &prefix, const String &suffix, bool putNumbersInBrackets=true) const
Definition juce_File.cpp:601
bool moveInternal(const File &) const
Definition juce_posix_SharedCode.h:404
bool hasReadAccess() const
Definition juce_posix_SharedCode.h:291
File getParentDirectory() const
Definition juce_File.cpp:358
String getVolumeLabel() const
Definition juce_posix_SharedCode.h:676
bool setFileTimesInternal(int64 m, int64 a, int64 c) const
Definition juce_posix_SharedCode.h:351
uint64 getFileIdentifier() const
Definition juce_posix_SharedCode.h:263
static juce_wchar getSeparatorChar()
Definition juce_posix_SharedCode.h:113
File()=default
bool deleteFile() const
Definition juce_posix_SharedCode.h:390
bool exists() const
Definition juce_posix_SharedCode.h:246
Result status
Definition juce_FileInputStream.h:82
void openHandle()
Definition juce_posix_SharedCode.h:439
const File file
Definition juce_FileInputStream.h:79
void * fileHandle
Definition juce_FileInputStream.h:80
~FileInputStream() override
Definition juce_posix_SharedCode.h:449
size_t readInternal(void *, size_t)
Definition juce_posix_SharedCode.h:455
ssize_t writeInternal(const void *, size_t)
Definition juce_posix_SharedCode.h:519
File file
Definition juce_FileOutputStream.h:109
int64 currentPosition
Definition juce_FileOutputStream.h:112
void openHandle()
Definition juce_posix_SharedCode.h:474
bool write(const void *, size_t) override
Definition juce_FileOutputStream.cpp:76
void flushInternal()
Definition juce_posix_SharedCode.h:533
void * fileHandle
Definition juce_FileOutputStream.h:110
Result status
Definition juce_FileOutputStream.h:111
Result truncate()
Definition juce_posix_SharedCode.h:540
void closeHandle()
Definition juce_posix_SharedCode.h:510
Definition juce_HeapBlock.h:87
void malloc(SizeType newNumElements, size_t elementSize=sizeof(ElementType))
Definition juce_HeapBlock.h:252
Definition juce_posix_SharedCode.h:1388
void next() noexcept
Definition juce_posix_SharedCode.h:1400
std::chrono::steady_clock::duration delta
Definition juce_posix_SharedCode.h:1407
Clock(std::chrono::steady_clock::rep millis) noexcept
Definition juce_posix_SharedCode.h:1390
bool wait(std::condition_variable &cond, std::unique_lock< std::mutex > &lock) noexcept
Definition juce_posix_SharedCode.h:1395
std::chrono::time_point< std::chrono::steady_clock > time
Definition juce_posix_SharedCode.h:1406
HighResolutionTimer()
Definition juce_HighResolutionTimer.cpp:26
Definition juce_posix_SharedCode.h:755
Pimpl(const String &lockName, int timeOutMillisecs)
Definition juce_posix_SharedCode.h:757
int handle
Definition juce_posix_SharedCode.h:839
void closeFile()
Definition juce_posix_SharedCode.h:821
bool createLockFile(const File &file, int timeOutMillisecs)
Definition juce_posix_SharedCode.h:779
~Pimpl()
Definition juce_posix_SharedCode.h:774
int refCount
Definition juce_posix_SharedCode.h:839
void close()
Definition juce_win32_Threads.cpp:343
std::unique_ptr< Pimpl > pimpl
Definition juce_InterProcessLock.h:113
~InterProcessLock()
Definition juce_posix_SharedCode.h:847
void exit()
Definition juce_posix_SharedCode.h:870
String name
Definition juce_InterProcessLock.h:116
bool enter(int timeOutMillisecs=-1)
Definition juce_posix_SharedCode.h:851
CriticalSection lock
Definition juce_InterProcessLock.h:115
InterProcessLock(const String &name)
Definition juce_posix_SharedCode.h:843
~MemoryMappedFile()
Definition juce_posix_SharedCode.h:599
void openInternal(const File &, AccessMode, bool)
Definition juce_posix_SharedCode.h:560
Range< int64 > range
Definition juce_MemoryMappedFile.h:102
int fileHandle
Definition juce_MemoryMappedFile.h:107
void * address
Definition juce_MemoryMappedFile.h:101
AccessMode
Definition juce_MemoryMappedFile.h:37
@ readWrite
Definition juce_MemoryMappedFile.h:39
@ readOnly
Definition juce_MemoryMappedFile.h:38
static void JUCE_CALLTYPE terminate()
Definition juce_posix_SharedCode.h:52
static Random & getSystemRandom() noexcept
Definition juce_Random.cpp:67
Definition juce_Range.h:40
Definition juce_Result.h:57
Definition juce_StringArray.h:35
static StringArray fromTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Definition juce_StringArray.cpp:387
int size() const noexcept
Definition juce_StringArray.h:136
void trim()
Definition juce_StringArray.cpp:266
Definition juce_String.h:53
static String toHexString(IntegerType number)
Definition juce_String.h:1097
CharPointer_UTF8 toUTF8() const
Definition juce_String.cpp:2070
Definition juce_StringRef.h:62
static String getEnvironmentVariable(const String &name, const String &defaultValue)
Definition juce_posix_SharedCode.h:550
Definition juce_Thread.h:43
size_t threadStackSize
Definition juce_Thread.h:391
static void JUCE_CALLTYPE setCurrentThreadAffinityMask(uint32 affinityMask)
Definition juce_posix_SharedCode.h:1047
void * ThreadID
Definition juce_Thread.h:304
Atomic< void * > threadHandle
Definition juce_Thread.h:386
void launchThread()
Definition juce_posix_SharedCode.h:918
static void JUCE_CALLTYPE yield()
Definition juce_posix_SharedCode.h:1033
void killThread()
Definition juce_posix_SharedCode.h:963
static ThreadID JUCE_CALLTYPE getCurrentThreadId()
Definition juce_posix_SharedCode.h:1028
static bool setThreadPriority(void *, int)
Definition juce_posix_SharedCode.h:993
static void JUCE_CALLTYPE setCurrentThreadName(const String &newThreadName)
Definition juce_posix_SharedCode.h:975
Atomic< ThreadID > threadId
Definition juce_Thread.h:387
void closeThreadHandle()
Definition juce_posix_SharedCode.h:957
uint32 affinityMask
Definition juce_Thread.h:392
static void JUCE_CALLTYPE sleep(int milliseconds)
Definition juce_posix_SharedCode.h:44
static int64 currentTimeMillis() noexcept
Definition juce_Time.cpp:220
Definition Array.h:57
static File getCurrentWorkingDirectory()
Definition File.cpp:1395
File getChildFile(StringRef relativeOrAbsolutePath) const
Definition File.cpp:418
const String & getFullPathName() const noexcept
Definition File.h:152
Definition StringArray.h:41
unsigned * m
Definition inflate.c:1559
struct huft * t
Definition inflate.c:943
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
unsigned f
Definition inflate.c:1572
static char filename[]
Definition features.c:5
static PuglViewHint int value
Definition pugl.h:1708
char * argv[]
Definition unzip.c:738
static const char * name
Definition pugl.h:1582
static uintptr_t parent
Definition pugl.h:1644
virtual ASIOError stop()=0
virtual ASIOError start()=0
CARLA_PLUGIN_EXPORT pid_t fork()
Definition interposer-safe.cpp:38
#define EXIT_FAILURE
Definition jerror.c:32
struct backing_store_struct * info
Definition jmemsys.h:183
JSAMPIMAGE data
Definition jpeglib.h:945
#define JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE(...)
Definition juce_CompilerWarnings.h:181
#define JUCE_END_IGNORE_WARNINGS_GCC_LIKE
Definition juce_CompilerWarnings.h:182
#define JUCE_AUTORELEASEPOOL
Definition juce_Memory.h:158
#define jassert(expression)
#define JUCE_DECLARE_NON_COPYABLE(className)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define jassertfalse
#define JUCE_CALLTYPE
#define JUCE_STAT
Definition juce_posix_SharedCode.h:175
unsigned int uint32_t
Definition mid.cpp:100
Definition carla_juce.cpp:31
void zerostruct(Type &structure) noexcept
Definition juce_Memory.h:32
int juce_siginterrupt(int sig, int flag)
Definition juce_posix_SharedCode.h:143
CriticalSection::ScopedLockType ScopedLock
Definition juce_CriticalSection.h:186
File juce_getExecutableFile()
Definition juce_posix_SharedCode.h:610
int64 juce_fileSetPosition(void *handle, int64 pos)
Definition juce_posix_SharedCode.h:431
unsigned long long uint64
Definition juce_MathsFunctions.h:56
constexpr Type jmap(Type value0To1, Type targetRangeMin, Type targetRangeMax)
Definition juce_MathsFunctions.h:120
constexpr Type jmin(Type a, Type b)
Definition juce_MathsFunctions.h:106
static bool hasEffectiveRootFilePermissions()
Definition juce_posix_SharedCode.h:269
unsigned int uint32
Definition juce_MathsFunctions.h:45
String juce_getOutputFromCommand(const String &)
Definition juce_posix_SharedCode.h:728
long long int64
Definition juce_MathsFunctions.h:54
wchar_t juce_wchar
Definition juce_CharacterFunctions.h:42
void ignoreUnused(Types &&...) noexcept
Definition juce_MathsFunctions.h:333
NSString * juceStringToNS(const String &s)
Definition juce_mac_ObjCHelpers.h:47
static bool setFileModeFlags(const String &fullPath, mode_t flags, bool shouldSet) noexcept
Definition juce_posix_SharedCode.h:297
static void * threadEntryProc(void *userData)
Definition juce_posix_SharedCode.h:886
void juce_runSystemCommand(const String &)
Definition juce_posix_SharedCode.h:721
int pointer_sized_int
Definition juce_MathsFunctions.h:80
@ exclusive
Definition juce_audio_devices.h:176
void JUCE_API juce_threadEntryPoint(void *userData)
Definition juce_Thread.cpp:116
jack_client_t client jack_client_t client jack_client_t client jack_client_t JackInfoShutdownCallback void arg jack_client_t jack_port_t port void func jack_client_t const char const char unsigned long flags
Definition juce_linux_JackAudio.cpp:69
@ Time
Definition LadspaBase.h:49
unsigned int uint32
Definition water.h:98
png_uint_32 length
Definition png.c:2247
png_structrp int mode
Definition png.h:1139
Definition juce_posix_SharedCode.h:1304
std::condition_variable stopCond
Definition juce_posix_SharedCode.h:1384
std::thread thread
Definition juce_posix_SharedCode.h:1383
static bool setThisThreadToRealtime(uint64 periodMs)
Definition juce_posix_SharedCode.h:1410
void start(int newPeriod)
Definition juce_posix_SharedCode.h:1315
~Pimpl()
Definition juce_posix_SharedCode.h:1309
std::mutex timerMutex
Definition juce_posix_SharedCode.h:1385
Pimpl(HighResolutionTimer &t)
Definition juce_posix_SharedCode.h:1305
std::atomic< int > periodMs
Definition juce_posix_SharedCode.h:1380
HighResolutionTimer & owner
Definition juce_posix_SharedCode.h:1379
void stop()
Definition juce_posix_SharedCode.h:1362
ZCONST char * key
Definition crypt.c:587
int error
Definition extract.c:1038
int flush(__G__ rawbuf, size, unshrink) __GDEF uch *rawbuf
int result
Definition process.c:1455
read(f, &c, 1)
int flag
Definition unix.c:754
char * getenv()
typedef int(UZ_EXP MsgFn)()
#define void
Definition unzip.h:396
#define SEEK_SET
Definition unzpriv.h:1302
Z_OFF_T lseek()
#define SEEK_END
Definition unzpriv.h:1304
struct zdirent * file
Definition win32.c:1500
#define const
Definition zconf.h:137