~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201207201942

« back to all changes in this revision

Viewing changes to lib/misc/util_misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-10-18 12:28:19 UTC
  • mfrom: (1.1.7 upstream) (2.4.9 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091018122819-00vqew6m0ztpqcqp
Tags: 2009.10.15-201664-1
MergingĀ upstreamĀ versionĀ 2009.10.15-201664.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
 *-----------------------------------------------------------------------------
91
91
 */
92
92
 
93
 
char*
94
 
Util_GetCanonicalPath(const char *path) // IN
 
93
char *
 
94
Util_GetCanonicalPath(const char *path)  // IN:
95
95
{
96
96
   char *canonicalPath = NULL;
 
97
 
97
98
#if defined(__linux__) || defined(__APPLE__)
98
99
   canonicalPath = Posix_RealPath(path);
99
100
#elif defined(_WIN32)
122
123
    *    assume remote.
123
124
    * 2. We do not resolve 8.3 names for remote paths.
124
125
    */
 
126
 
125
127
   if (remoteDrive) {
126
128
      canonicalPath = strdup(path);
127
129
   } else {
156
158
 */
157
159
 
158
160
char *
159
 
Util_GetCanonicalPathForHash(const char *path) // IN: UTF-8
 
161
Util_GetCanonicalPathForHash(const char *path)  // IN: UTF-8
160
162
{
161
163
   char *ret = NULL;
162
164
   char *cpath = Util_GetCanonicalPath(path);
191
193
 */
192
194
 
193
195
static char*
194
 
UtilGetLegacyEncodedString(const char *path) // IN: UTF-8
 
196
UtilGetLegacyEncodedString(const char *path)  // IN: UTF-8
195
197
{
196
198
   char *ret = NULL;
197
199
   char *cpath = Util_GetCanonicalPath(path);
239
241
 *-----------------------------------------------------------------------------
240
242
 */
241
243
 
242
 
char*
243
 
Util_CompatGetCanonicalPath(const char *path) // IN: UTF-8
 
244
char *
 
245
Util_CompatGetCanonicalPath(const char *path)  // IN: UTF-8
244
246
{
245
247
   char *cpath = Util_GetCanonicalPath(path);
246
248
   char *ret = NULL;
265
267
 *      path case-sensitivity.
266
268
 *
267
269
 *      XXX: This implementation makes assumptions about the host filesystem's
268
 
 *           case sensitivity without any regard to what filesystem the provided
269
 
 *           paths actually use. There are many ways to break this assumption,
270
 
 *           on any of our supported host OSes! The return value of this function
271
 
 *           cannot be trusted.
 
270
 *           case sensitivity without any regard to what filesystem the
 
271
 *           provided paths actually use. There are many ways to break this
 
272
 *           assumption, on any of our supported host OSes! The return value
 
273
 *           of this function cannot be trusted.
272
274
 *
273
275
 * Results:
274
276
 *      TRUE if the paths are equivalenr, FALSE if they are not.
280
282
 */
281
283
 
282
284
Bool
283
 
Util_CanonicalPathsIdentical(const char *path1, // IN
284
 
                             const char *path2) // IN
 
285
Util_CanonicalPathsIdentical(const char *path1,  // IN:
 
286
                             const char *path2)  // IN:
285
287
{
286
288
   ASSERT(path1);
287
289
   ASSERT(path2);
 
290
 
288
291
#if defined(linux)
289
292
   return (strcmp(path1, path2) == 0);
290
293
#elif defined(_WIN32)
360
363
 */
361
364
 
362
365
unsigned
363
 
Util_GetPrime(unsigned n0)
 
366
Util_GetPrime(unsigned n0)  // IN:
364
367
{
365
368
   unsigned i, ii, n, nn;
366
369
 
384
387
       * 65521 is the largest prime below 0xffff, which is where
385
388
       * we can stop.  Using it instead of 0xffff avoids overflowing ii.
386
389
       */
 
390
 
387
391
      nn = MIN(n, 65521U * 65521U);
388
392
      for (i = 3, ii = 9;; ii += 4*i+4, i += 2) {
389
393
         if (ii > nn) {
405
409
 * gettid --
406
410
 *
407
411
 *      Retrieve unique thread identification suitable for kill or setpriority.
408
 
 *      Do not call this function directly, use Util_GetCurrentThreadId() instead.
 
412
 *      Do not call this function directly, use Util_GetCurrentThreadId()
 
413
 *      instead.
409
414
 *
410
415
 * Results:
411
416
 *      Unique thread identification on success.
481
486
   }
482
487
   tid = getpid();
483
488
   ASSERT(tid != (pid_t)-1);
 
489
 
484
490
   return tid;
485
491
#elif defined(sun)
486
492
   pid_t tid;
487
493
 
488
494
   tid = getpid();
489
495
   ASSERT(tid != (pid_t)-1);
 
496
 
490
497
   return tid;
491
498
#elif defined(__APPLE__) || defined(__FreeBSD__)
492
499
   ASSERT_ON_COMPILE(sizeof(Util_ThreadID) == sizeof(pthread_t));
 
500
 
493
501
   return pthread_self();
494
502
#elif defined(_WIN32)
495
503
   return GetCurrentThreadId();