Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
JawnV6
Jul 4, 2004

So hot ...

Arcsech posted:

maybe i have stockholm syndrome for bit-twiddling c, but that actually isn't too bad to read to figure out what its doing

but if you dont have a comment explaining why its doing that, then gently caress you
i ended up trashing it in favor of using a ring buffer and not tracking per-block usage, but it made it into version control

Arcsech posted:

also use #defines for the 3 and 0x7 so its clearer about what those actually represent
and avoid the type system!?!?

it probably makes more sense on a few lines as
code:
uint8_t byte_index = (block >>3);
uint8_t bit_index = (block&0x7);
block_used[byte_index] |= (1<<bit_index);
or just to be terrible about it
code:
 typedef struct block_index {
    unsigned int bit_index:3;
    unsigned int byte_index:5;
} block_index_t;
block_index_t bInd = (block_index_t) block;
block_used[bInd.byte_index] |= (1<<bInd.bit_index);

Adbot
ADBOT LOVES YOU

Jeffrey of YOSPOS
Dec 22, 2005

GET LOSE, YOU CAN'T COMPARE WITH MY POWERS
My paranoid rear end would put __attribute__ ((__packed__)) on that struct, dunno if it's really needed.

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

Jeffrey of YOSPOS posted:

Improvements are pretty ugly too:
code:
block_used[(block >> BLOCK_FIELD2_SHIFT) & BLOCK_FIELD2_MASK]  |= ((1 << (block >> BLOCK_FIELD1_SHIFT) & BLOCK_FIELD1_MASK);
You can do more tricks to make it smaller if you do this all with macros or something, but it's ugly either way.

I think normally the nice thing to do would be to make (block >> BLOCK_FIELD2_SHIFT) & BLOCK_FIELD2_MASK type things local variables so you get

code:
uint8_t block_addr = block>>3;
uint8_t block_set_bit = 1<<(block & 0x07);

block[block_addr] |= block_set_bit; 

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

JawnV6 posted:

i ended up trashing it in favor of using a ring buffer and not tracking per-block usage, but it made it into version control

and avoid the type system!?!?

it probably makes more sense on a few lines as
code:
uint8_t byte_index = (block >>3);
uint8_t bit_index = (block&0x7);
block_used[byte_index] |= (1<<bit_index);
or just to be terrible about it
code:
 typedef struct block_index {
    unsigned int bit_index:3;
    unsigned int byte_index:5;
} block_index_t;
block_index_t bInd = (block_index_t) block;
block_used[bInd.byte_index] |= (1<<bInd.bit_index);

yeah do that first one.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Shaggar posted:

I did a powershell script for a thing and powershell is still kind of dumb because why didn't they just use c# syntax, but the one thing I do like is you can sign scripts and require signatures for scripts to run. that's cool and way better than Linux where the bad scripting language is not just the UI, but its unrestricted.

the new visual studio update has the c# interpreter in it. I'm actually not sure if you can run c# script files with it but I presume so since it seems a straight clone of f#'s fsi.exe

of course neither are shipped with windows unlike power shell. this may or may not be a showstopper fit you. sadly it is for me

sarehu
Apr 20, 2007

(call/cc call/cc)

JawnV6 posted:

code:
block_used[(block>>3)] |= (1<<(block&0x7));
this is the kind of thing people hate, right?

No it's good.

JawnV6 posted:

code:
uint8_t byte_index = (block >>3);
uint8_t bit_index = (block&0x7);
block_used[byte_index] |= (1<<bit_index);

Now your byte index has been truncated to an 8-bit value.

Using 0x7 is nauseating though.

Jeffrey of YOSPOS
Dec 22, 2005

GET LOSE, YOU CAN'T COMPARE WITH MY POWERS
please don't use bitwise operators with decimal numbers

Soricidus
Oct 21, 2010
freedom-hating statist shill

Arcsech posted:

maybe i have stockholm syndrome for bit-twiddling c, but that actually isn't too bad to read to figure out what its doing

but if you dont have a comment explaining why its doing that, then gently caress you

also use #defines for the 3 and 0x7 so its clearer about what those actually represent

#define SHIFT_VALUE_THREE 3
#define MASK_VALUE_SEVEN 0x7

Shaggar
Apr 26, 2006

NihilCredo posted:

the new visual studio update has the c# interpreter in it. I'm actually not sure if you can run c# script files with it but I presume so since it seems a straight clone of f#'s fsi.exe

of course neither are shipped with windows unlike power shell. this may or may not be a showstopper fit you. sadly it is for me
Windows doesn't ship with updated PowerShell either. I had to install PowerShell 4 to get a cmdlet i wanted. Idk why it's not distributed via windows update.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i tried to do some stuff with node today because i wanted to demonstrate that some json-schema poo poo wasn't working, and i wanted to use like, a well vetted json-schema library to show it (rather than the one i was using )

turns out all the js json schema validators on node are like, kinda poo poo?

i found a library that would asynchronously pull in missing schemas so i used that one.

it failed because the library used jquery to do its async stuff.

jquery requires a window.document to work (apparently)

a library, available in node, uses jquery to do async stuff, and cant, because node does not have a browser window. shouldn't node have all kinds of much better things than jquery to do async things??

i just dont get it. where does browser JS end and node js begin?

pseudorandom name
May 6, 2007

Shaggar posted:

Windows doesn't ship with updated PowerShell either. I had to install PowerShell 4 to get a cmdlet i wanted. Idk why it's not distributed via windows update.

it does get distributed via windows update, its just bundled with some other stuff

you can read about it in KB3035583

zeekner
Jul 14, 2007

MALE SHOEGAZE posted:

i just dont get it. where does browser JS end and node js begin?

people use NPM and webpack to do node-style development targetting browsers, so there are a ton of packages that are browser-only on npm

no way to tell unless they specifically state it in their docs

lol, js docs

sarehu
Apr 20, 2007

(call/cc call/cc)

Trigger warning please

JawnV6
Jul 4, 2004

So hot ...

sarehu posted:

Using 0x7 is nauseating though.

0b111?

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Jerry Bindle
May 16, 2003

i wish c had binary literals :(

Bloody
Mar 3, 2013

JawnV6 posted:

code:
block_used[(block>>3)] |= (1<<(block&0x7));
this is the kind of thing people hate, right?

code:
block_used(block >> 3)] |= 1 << (block & 0x07);

MrMoo
Sep 14, 2000

Barnyard Protein posted:

i wish c had binary literals :(

apparently GCC supports them.

qntm
Jun 17, 2009

Barnyard Protein posted:

i wish c had binary literals :(

it boggles my mind that there exists a single programming language in the whole world which doesn't support binary literals, let alone that C of all languages has this problem

Jerry Bindle
May 16, 2003
oh awesome! thanks! sometimes wishes do come true

suffix
Jul 27, 2013

Wheeee!

JawnV6 posted:

code:
block_used[(block>>3)] |= (1<<(block&0x7));
this is the kind of thing people hate, right?

code:
/*
 * Mark a block as used in the used block bitmap.
 *
 * Passing a block_num >= MAX_BLOCK_NUM results in undefined behaviour, the caller must check this!
 */
inline void mark_block_as_used(uint8_t used_block_bitmap[], size_t block_num) {
        assert(block_num < MAX_BLOCK_NUM);
        // Used blocks are stored as a bitmap, so we divide block_num with eight to get the byte,
        // then take block_num modulo eight to find the bit position to set.
        used_block_bitmap[block_num >> 3] |= 1 << (block_num & 0x7);
}

Soricidus
Oct 21, 2010
freedom-hating statist shill
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue

idk if this is vs or .net or windows or what but lmfao at whatever it is

Bloody
Mar 3, 2013


4'b0111?

Shaggar
Apr 26, 2006

pseudorandom name posted:

it does get distributed via windows update, its just bundled with some other stuff

you can read about it in KB3035583

I had the machine up to date and still had to install it manually.

JawnV6
Jul 4, 2004

So hot ...

Barnyard Protein posted:

i wish c had binary literals :(
i tested that before i posted, WORKSFORME on my dodgy gcc shard that doesn't respect falter cases

Bloody posted:

4'b0111?
psh, i wish i could still specify things outside these crude 8-bit boundaries

although i am using a part with 24bit results

Luigi Thirty
Apr 30, 2006

Emergency confection port.

i updated vs2015 to update 1 and now it doesn't work! it just freezes on startup

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Barnyard Protein posted:

i wish c had binary literals :(

just use c++14

fritz
Jul 26, 2003


07

triple sulk
Sep 17, 2014



Luigi Thirty posted:

i updated vs2015 to update 1 and now it doesn't work! it just freezes on startup

are you opening a project right from startup or is it just the home page

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

JawnV6 posted:

or just to be terrible about it
code:
 typedef struct block_index {
    unsigned int bit_index:3;
    unsigned int byte_index:5;
} block_index_t;
block_index_t bInd = (block_index_t) block;
block_used[bInd.byte_index] |= (1<<bInd.bit_index);

you can't just cast that

do something like
code:

typedef union block_index {
    uint8_t raw;
    struct {
    unsigned int bit_index:3;
    unsigned int byte_index:5;
    } cooked;
} block_index_t;
block_index_t bInd;
bInd.raw = block;
block_used[bInd.cooked.byte_index] |= (1<<bInd.cooked.bit_index);

redleader
Aug 18, 2005

Engage according to operational parameters

Shaggar posted:

I did a powershell script for a thing and powershell is still kind of dumb because why didn't they just use c# syntax, but the one thing I do like is you can sign scripts and require signatures for scripts to run. that's cool and way better than Linux where the bad scripting language is not just the UI, but its unrestricted.

for a language designed around piping objects around, it's baffling that powershell has no convenient way of creating a custom object to sling through the pipeline. i'd really, really like the ability to jam a few fields into some ad hoc object, a la c# or js, but in powershell creating an object is just gross

i really wanted to like powershell, but there are so many annoying gotchas (how do you gently caress up multidimensional lists so badly?) that i just can't. it's so, so awkward in practice. powershell should just have been a more dynamically-typed c# with some additional linqy stuff and syntax to make typical scripty tasks easier

~Coxy
Dec 9, 2003

R.I.P. Inter-OS Sass - b.2000AD d.2003AD

Soricidus posted:

Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue

idk if this is vs or .net or windows or what but lmfao at whatever it is

it's an assertion; it's meant to be a low level failsafe for programmers and it doesn't get included in release builds

Soricidus
Oct 21, 2010
freedom-hating statist shill

~Coxy posted:

it's an assertion; it's meant to be a low level failsafe for programmers and it doesn't get included in release builds

yes? that doesn't really excuse a crazy interface where the buttons have incorrect labels and the correct labels are given in the dialog title instead

Luigi Thirty
Apr 30, 2006

Emergency confection port.

triple sulk posted:

are you opening a project right from startup or is it just the home page

the start page

I get that Windows error sound and it acts like there's a modal dialog up but nothing appears

Shaggar
Apr 26, 2006

redleader posted:

for a language designed around piping objects around, it's baffling that powershell has no convenient way of creating a custom object to sling through the pipeline. i'd really, really like the ability to jam a few fields into some ad hoc object, a la c# or js, but in powershell creating an object is just gross

i really wanted to like powershell, but there are so many annoying gotchas (how do you gently caress up multidimensional lists so badly?) that i just can't. it's so, so awkward in practice. powershell should just have been a more dynamically-typed c# with some additional linqy stuff and syntax to make typical scripty tasks easier

you can create maps like $aThing = @{ SomeProp="fffff", whatever="guuuuhhhhh" } and then $aThing.SomeProp or $aThing.whatever. I haven't done much diving into the syntax cause I was doing something pretty simple.

Shaggar
Apr 26, 2006
I would guess that maybe

$butts = @{ boners=@{ whatever="FFFF"} } might work too? idk.

Baxate
Feb 1, 2011

MALE SHOEGAZE posted:

i tried to do some stuff with node today because i wanted to demonstrate that some json-schema poo poo wasn't working, and i wanted to use like, a well vetted json-schema library to show it (rather than the one i was using )

turns out all the js json schema validators on node are like, kinda poo poo?

i found a library that would asynchronously pull in missing schemas so i used that one.

it failed because the library used jquery to do its async stuff.

jquery requires a window.document to work (apparently)

a library, available in node, uses jquery to do async stuff, and cant, because node does not have a browser window. shouldn't node have all kinds of much better things than jquery to do async things??

i just dont get it. where does browser JS end and node js begin?

doesn't node like fire up a whole freaking instance of chrome in order to do things
last time i tried to install node with homebrew it would like try to compile chrome from source and i'm like yeah... nope ^C

Luigi Thirty
Apr 30, 2006

Emergency confection port.

http://youtu.be/FuMUYFFSV7Y

behold the power of the laserdisc

now I want to know what that ran on in 1982

e: I can find out if I want to spend 15 dollars http://spie.org/Publications/Proceedings/Paper/10.1117/12.935588

Luigi Thirty fucked around with this message at 16:33 on Dec 3, 2015

triple sulk
Sep 17, 2014



swift got open sourced it seems like (or will be)

Adbot
ADBOT LOVES YOU

leftist heap
Feb 28, 2013

Fun Shoe
i like swift. i hope the OS version takes off but i have my doubts

  • Locked thread